Page MenuHomePhabricator

PECOFF: Fix section name computation
ClosedPublic

Authored by labath on Fri, Dec 28, 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
rL LLVM

Event Timeline

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

What about just making this function return a StringRef?

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

An excellent idea. Updating to use StringRef.

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