mirror of
https://github.com/avast/retdec.git
synced 2024-12-18 02:48:01 +00:00
Change the section name parsing to only remove trailing zeroes (#979)
* Change the section name parsing to only rstrip zeroes * Remove accidental <algorithm> include * Change formatting to match the existing code style
This commit is contained in:
parent
bde3eb5753
commit
3d506f212f
@ -1842,16 +1842,21 @@ int PeLib::ImageLoader::captureSectionName(
|
||||
|
||||
// The section name is directly in the section header.
|
||||
// It has fixed length and must not be necessarily terminated with zero.
|
||||
// Historically, PELIB copies the name of the section WITHOUT zero chars,
|
||||
// even if the zero chars are in the middle. Aka ".text\0\0X" results in ".textX"
|
||||
sectionName.clear();
|
||||
for(size_t i = 0; i < PELIB_IMAGE_SIZEOF_SHORT_NAME; i++)
|
||||
|
||||
// rstrip trailing nulls
|
||||
const uint8_t* end = Name + PELIB_IMAGE_SIZEOF_SHORT_NAME;
|
||||
// find the first non-null from end
|
||||
do
|
||||
{
|
||||
if(Name[i])
|
||||
{
|
||||
sectionName += Name[i];
|
||||
}
|
||||
end--;
|
||||
} while (end - Name > 0 && *end == 0);
|
||||
|
||||
if (end - Name > 0)
|
||||
{
|
||||
sectionName.assign(Name, end + 1);
|
||||
}
|
||||
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user