This is an archive of the discontinued LLVM Phabricator instance.

[Object, MachO] Don't crash on invalid MachO load commands.
ClosedPublic

Authored by samsonov on Jun 3 2015, 5:31 PM.

Details

Reviewers
filcab
rafael
Summary

Currently all load commands are parsed in MachOObjectFile constructor.
If the next load command cannot be parsed, or if command size are too
small, properly report it through the error code and fail to construct
the object, instead of crashing the program.

Diff Detail

Event Timeline

samsonov updated this revision to Diff 27076.Jun 3 2015, 5:31 PM
samsonov retitled this revision from to [Object, MachO] Don't crash on invalid MachO load segments..
samsonov updated this object.
samsonov edited the test plan for this revision. (Show Details)
samsonov added reviewers: rafael, filcab.
samsonov added a subscriber: Unknown Object (MLST).
samsonov retitled this revision from [Object, MachO] Don't crash on invalid MachO load segments. to [Object, MachO] Don't crash on invalid MachO load commands..Jun 3 2015, 6:02 PM
samsonov updated this object.
filcab added inline comments.Jun 3 2015, 6:30 PM
test/Object/macho-invalid.test
4

Please commit this formatting change separately, then add the case for this patch.

6

Please commit this formatting change separately (for all the previous tests), then do the patch for this case, removing the "not".

filcab accepted this revision.Jun 3 2015, 6:31 PM
filcab edited edge metadata.

(forgot to LGTM)

LGTM, as long as the formatting change gets its own commit.

This revision is now accepted and ready to land.Jun 3 2015, 6:31 PM
rafael edited edge metadata.Jun 3 2015, 11:19 PM

llvm-objdump should still exit with a non-zero status, no ?

samsonov added inline comments.Jun 4 2015, 11:54 AM
test/Object/macho-invalid.test
4

Done in r239068.

samsonov closed this revision.Jun 4 2015, 1:02 PM

r239080.