dump: fix note_name_equal()
PATCH 1/1 dump: fix note_name_equal()
Use the function argument "name" instead of hardcoded "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't an exposed bug, thankfully.
Simplify a little bit the code while touching this.
Suggested-by Andrew Jones <[email protected]>
Reported-by Laszlo Ersek <[email protected]>
Signed-off-by Marc-André Lureau <[email protected]>
--- dump.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
dump.c +1 -6
@@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,get_note_sizes (s, note, &head_size, &name_size,NULL ); head_size =ROUND_UP (head_size,4 ); -if (name_size != len || -memcmp (note + head_size,"VMCOREINFO" , len)) { -return false; - } - -return true; +return name_size == len &&memcmp (note + head_size, name, len) ==0 ; }/* write common header, sub header and elf note to vmcore */
Signature · 1 line
2.15.1.355.g36791d7216
Quoted 22 lines · Marc-André Lureau
Use the function argument "name" instead of hardcoded "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't an exposed bug, thankfully.
Simplify a little bit the code while touching this.
Suggested-by Andrew Jones <[email protected]>Reported-by Laszlo Ersek <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- dump.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)dump.c +0
-0@@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,get_note_sizes (s, note, &head_size, &name_size,NULL ); head_size =ROUND_UP (head_size,4 );
dump.c static bool note_name_equal(DumpState *s, · line 794
Quoted 10 lines
dump.c +1
-6-if (name_size != len || -memcmp (note + head_size,"VMCOREINFO" , len)) { -return false; - } - -return true; +return name_size == len &&memcmp (note + head_size, name, len) ==0 ; }/* write common header, sub header and elf note to vmcore */
Reviewed-by Laszlo Ersek <[email protected]>
Quoted 34 lines · Marc-André Lureau
Use the function argument "name" instead of hardcoded "VMCOREINFO". All callers use "VMCOREINFO" as argument, so this isn't an exposed bug, thankfully.
Simplify a little bit the code while touching this.
Suggested-by Andrew Jones <[email protected]>Reported-by Laszlo Ersek <[email protected]>Signed-off-by Marc-André Lureau <[email protected]>--- dump.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)dump.c +1
-6@@ -788,12 +788,7 @@ static bool note_name_equal(DumpState *s,get_note_sizes (s, note, &head_size, &name_size,NULL ); head_size =ROUND_UP (head_size,4 ); -if (name_size != len || -memcmp (note + head_size,"VMCOREINFO" , len)) { -return false; - } - -return true; +return name_size == len &&memcmp (note + head_size, name, len) ==0 ; }/* write common header, sub header and elf note to vmcore */ Signature · 1 line
2.15.1.355.g36791d7216
Reviewed-by Andrew Jones <[email protected]>