File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,10 @@ impl BootLoaderNameTag {
2525 #[ cfg( feature = "builder" ) ]
2626 pub fn new ( name : & str ) -> Box < Self > {
2727 let mut bytes: Vec < _ > = name. bytes ( ) . collect ( ) ;
28- bytes. push ( 0 ) ;
28+ if !bytes. ends_with ( & [ 0 ] ) {
29+ // terminating null-byte
30+ bytes. push ( 0 ) ;
31+ }
2932 boxed_dst_tag ( TagType :: BootLoaderName , & bytes)
3033 }
3134
Original file line number Diff line number Diff line change @@ -32,7 +32,10 @@ impl CommandLineTag {
3232 #[ cfg( feature = "builder" ) ]
3333 pub fn new ( command_line : & str ) -> Box < Self > {
3434 let mut bytes: Vec < _ > = command_line. bytes ( ) . collect ( ) ;
35- bytes. push ( 0 ) ;
35+ if !bytes. ends_with ( & [ 0 ] ) {
36+ // terminating null-byte
37+ bytes. push ( 0 ) ;
38+ }
3639 boxed_dst_tag ( TagType :: Cmdline , & bytes)
3740 }
3841
Original file line number Diff line number Diff line change @@ -30,7 +30,10 @@ impl ModuleTag {
3030 #[ cfg( feature = "builder" ) ]
3131 pub fn new ( start : u32 , end : u32 , cmdline : & str ) -> Box < Self > {
3232 let mut cmdline_bytes: Vec < _ > = cmdline. bytes ( ) . collect ( ) ;
33- cmdline_bytes. push ( 0 ) ;
33+ if !cmdline_bytes. ends_with ( & [ 0 ] ) {
34+ // terminating null-byte
35+ cmdline_bytes. push ( 0 ) ;
36+ }
3437 let start_bytes = start. to_le_bytes ( ) ;
3538 let end_bytes = end. to_le_bytes ( ) ;
3639 let mut content_bytes = [ start_bytes, end_bytes] . concat ( ) ;
You can’t perform that action at this time.
0 commit comments