Commit Graph

9 Commits

Author SHA1 Message Date
Alexey Samsonov
62d21d2b1a [Object, MachO] Don't crash on incomplete MachO segment load commands.
Report proper error code from MachOObjectFile constructor if we
can't parse another segment load command (we already return a proper
error if segment load command contents is suspicious).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239109 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 22:26:44 +00:00
Alexey Samsonov
5400980e1e [Object, MachO] Don't crash on invalid MachO segment load commands.
Summary:
Properly report the error in segment load commands from MachOObjectFile
constructor instead of crashing the program.

Adjust the test case accordingly.

Test Plan: regression test suite

Reviewers: rafael, filcab

Subscribers: llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239081 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 20:08:52 +00:00
Alexey Samsonov
7e699dce03 [Object, MachO] Don't crash on invalid MachO load commands.
Summary:
Currently all load commands are parsed in MachOObjectFile constructor.
If the next load command cannot be parsed, or if command size is too
small, properly report it through the error code and fail to construct
the object, instead of crashing the program.

Test Plan: regression test suite

Reviewers: rafael, filcab

Subscribers: llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239080 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 19:57:46 +00:00
Alexey Samsonov
1d4ec71798 [Object, MachO] Don't crash on parsing invalid MachO header.
Summary: Instead, properly report this error from MachOObjectFile constructor.

Test Plan: regression test suite

Reviewers: rafael

Subscribers: llvm-commits

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239078 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 19:45:22 +00:00
Alexey Samsonov
3391374181 Make test case more readable: move CHECK-lines next to corresponding RUN-lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239068 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-04 18:50:04 +00:00
Rafael Espindola
7b677dd986 Stop inventing symbol sizes.
MachO and COFF quite reasonably only define the size for common symbols.

We used to try to figure out the "size" by computing the gap from one symbol to
the next.

This would not be correct in general, since a part of a section can belong to no
visible symbol (padding, private globals).

It was also really expensive, since we would walk every symbol to find the size
of one.

If a caller really wants this, it can sort all the symbols once and get all the
gaps ("size") in O(n log n) instead of O(n^2).

On MachO this also has the advantage of centralizing all the checks for an
invalid n_sect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238028 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 15:43:00 +00:00
Rafael Espindola
cc3f1db34c Detect invalid section indexes when we first read them.
We still detect the same errors, but now we do it earlier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238024 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-22 14:59:27 +00:00
Filipe Cabecinhas
909dd28c54 Fix edge case when Start overflowed in 32 bit mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226229 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 23:50:44 +00:00
Filipe Cabecinhas
0183477621 Report fatal errors instead of segfaulting/asserting on a few invalid accesses while reading MachO files.
Summary:
Shift an older “invalid file” test to get a consistent naming for these tests.

Bugs found by afl-fuzz

Reviewers: rafael

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6945

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226219 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 22:52:38 +00:00