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 {
25
25
#[ cfg( feature = "builder" ) ]
26
26
pub fn new ( name : & str ) -> Box < Self > {
27
27
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
+ }
29
32
boxed_dst_tag ( TagType :: BootLoaderName , & bytes)
30
33
}
31
34
Original file line number Diff line number Diff line change @@ -32,7 +32,10 @@ impl CommandLineTag {
32
32
#[ cfg( feature = "builder" ) ]
33
33
pub fn new ( command_line : & str ) -> Box < Self > {
34
34
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
+ }
36
39
boxed_dst_tag ( TagType :: Cmdline , & bytes)
37
40
}
38
41
Original file line number Diff line number Diff line change @@ -30,7 +30,10 @@ impl ModuleTag {
30
30
#[ cfg( feature = "builder" ) ]
31
31
pub fn new ( start : u32 , end : u32 , cmdline : & str ) -> Box < Self > {
32
32
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
+ }
34
37
let start_bytes = start. to_le_bytes ( ) ;
35
38
let end_bytes = end. to_le_bytes ( ) ;
36
39
let mut content_bytes = [ start_bytes, end_bytes] . concat ( ) ;
You can’t perform that action at this time.
0 commit comments