mirror of
https://github.com/serge1/ELFIO.git
synced 2025-01-30 15:32:44 +00:00
Fixed off-by-one error in 'name' of add_note() function.
Previously, when assigning 'name' as a string, it's length was specified using the full length of 'namesz'. However, this length includes the trailing '\0' of the underlying char[]. This ultimately causes the C++ string that is created to (incorrectly) contain the '\0' character as well. This leads to problems where e.g. the following will return false, even when 'name' itself actually contains the string "GNU\0": if (name == "GNU") { return true; } return false; To fix this, we should only include the length of the string minus the trailing '\0'.
This commit is contained in:
parent
8e7a29e128
commit
e3e0d6dbdb
@ -66,7 +66,7 @@ class note_section_accessor
|
|||||||
namesz + descSize > max_name_size ) {
|
namesz + descSize > max_name_size ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
name.assign( pData + 3 * sizeof( Elf_Word ), namesz );
|
name.assign( pData + 3 * sizeof( Elf_Word ), namesz - 1);
|
||||||
if ( 0 == descSize ) {
|
if ( 0 == descSize ) {
|
||||||
desc = 0;
|
desc = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user