Page MenuHomePhabricator

Ensure that trailing characters aren't included in PECOFF section names
Needs RevisionPublic

Authored by fjricci on Mar 2 2018, 12:46 PM.



If a section name is exactly 8 characters (the maximum section name length),
and the next item in the section header struct contains a non-zero value,
we would append garbage data to the end of the section name string due to the
lack of null-termination. Ensure that we don't construct the section name
with more than sizeof( characters.

Event Timeline

fjricci created this revision.Mar 2 2018, 12:46 PM
wallace accepted this revision.Mar 2 2018, 12:49 PM

good catch

This revision is now accepted and ready to land.Mar 2 2018, 12:49 PM
labath added a subscriber: labath.Mar 2 2018, 1:07 PM

Is it possible to test this? Is it possible to make yaml2obj generate a file that would trigger this?

Just compile something with /Z7 and you'll get a section called .debug$S in the object file, which is exactly 8 characters. Then teach lldb-test to dump an object file's sections.

clayborg requested changes to this revision.Mar 2 2018, 2:30 PM
clayborg added inline comments.

This is storing any extra NULL characters in sect_name. Might be better to do:

sect_name = std::string(, strnlen(, sizeof(;
This revision now requires changes to proceed.Mar 2 2018, 2:30 PM

Add test as well.

Will we have the same problem with coff_symbol?

wallace resigned from this revision.Oct 15 2019, 2:39 PM