Page MenuHomePhabricator

[llvm-readobj] - --gnu-hash-table: do not crash when the GNU hash table goes past the EOF.
ClosedPublic

Authored by grimar on Wed, May 13, 5:15 AM.

Details

Summary

We might have a scenario where a the GbuHashTable variable correctly points
to a place inside the file (we validate this fact early in parseDynamicTable),
but nbuckets/maskwords fields are broken in the way the code tries
to read the data past the EOF. This patch fixes the issue.

Diff Detail

Event Timeline

grimar created this revision.Wed, May 13, 5:15 AM
Herald added a project: Restricted Project. · View Herald Transcript
MaskRay accepted this revision.Wed, May 13, 9:28 AM

LGTM.

llvm/tools/llvm-readobj/ELFDumper.cpp
2681

IIRC this is guaranteed by ELFFile<ELFT>::toMappedAddr

This revision is now accepted and ready to land.Wed, May 13, 9:28 AM
jhenderson accepted this revision.Thu, May 14, 12:07 AM

LGTM, with one suggestion.

llvm/test/tools/llvm-readobj/ELF/gnuhash.test
323–324

I'd probably put these lines with their respective cases, since they're only used once.

grimar marked 2 inline comments as done.Fri, May 15, 1:34 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
2681

Yes.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.