Homebrew/ruby-macho

Fat parser should fail on file with 0 architectures

woodruffw opened this issue · 1 comments

Currently, ruby-macho will happily parse a fat Mach-O with no internal slices (i.e., nfat_arch == 0). This should be an error (potentially an ignorable one with permissive: true).

Reference this LLVM object: https://github.com/llvm-mirror/llvm/blob/master/test/Object/Inputs/macho-invalid-fat-header

Observed behavior:

>> MachO.open('macho-invalid-fat-header')
#<MachO::FatFile:0x000055776df6b2a8 @filename="macho-invalid-fat-header", @options={}, @raw_data="\xCA\xFE\xBA\xBE\x00\x00\x00\x00", @header=#<MachO::Headers::FatHeader:0x000055776df6b118 @magic=3405691582, @nfat_arch=0>, @fat_archs=[], @machos=[]>

Expected behavior:

An exception.

Fixed with #449 a long time ago.