Basic error checking for mach-o
authorAlan Modra <amodra@gmail.com>
Sun, 5 Jan 2020 23:31:55 +0000 (10:01 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 6 Jan 2020 11:23:51 +0000 (21:53 +1030)
commit3e6aa7751ab86fdc2f2762ed8a5bce41b22be56e
tree1308ae262b43b4cf0a34b1d97e68aadea54ee9b9
parent660e62b1d9ca02e4ec7b18e8f0a0ff0707e540ac
Basic error checking for mach-o

Fixes lots of places the fuzzers are going to find, and the one they
already hit.

* mach-o.c (bfd_mach_o_read_dylinker): Don't read past end of
command.  Check name offset is within command.
(bfd_mach_o_read_dylib, bfd_mach_o_read_prebound_dylib),
(bfd_mach_o_read_prebind_cksum, bfd_mach_o_read_twolevel_hints),
(bfd_mach_o_read_fvmlib, bfd_mach_o_read_dysymtab),
(bfd_mach_o_read_symtab, bfd_mach_o_read_uuid),
(bfd_mach_o_read_linkedit, bfd_mach_o_read_str),
(bfd_mach_o_read_dyld_info, bfd_mach_o_read_version_min),
(bfd_mach_o_read_encryption_info, bfd_mach_o_read_source_version),
(bfd_mach_o_read_encryption_info_64, bfd_mach_o_read_main),
(bfd_mach_o_read_note, bfd_mach_o_read_build_version),
(bfd_mach_o_read_segment): Similarly.
(bfd_mach_o_read_thread): Properly bound check thread struct.
Don't repeat checks on second loop.
(bfd_mach_o_read_command): Fail on invalid command length.
bfd/ChangeLog
bfd/mach-o.c