This is an archive of the discontinued LLVM Phabricator instance.

PECOFF: Fix section name computation
ClosedPublic

Authored by labath on Dec 28 2018, 2:32 AM.

Details

Summary
If a section name is exactly 8 bytes long (or has been truncated to 8
bytes), it will not contain the terminating nul character. This means
reading the name as a c string will pick up random data following the
name field (which happens to be the section vm size).

This fixes the name computation to avoid out-of-bounds access and adds a
test.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

labath created this revision.Dec 28 2018, 2:32 AM

What about just making this function return a StringRef?

labath updated this revision to Diff 179644.Dec 28 2018, 9:22 AM

An excellent idea. Updating to use StringRef.

zturner accepted this revision.Dec 29 2018, 1:43 PM
This revision is now accepted and ready to land.Dec 29 2018, 1:43 PM
This revision was automatically updated to reflect the committed changes.