aaronst / macholibre

Mach-O & Universal Binary Parser
Apache License 2.0
143 stars 32 forks source link

UnboundLocalError in parse_syms #15

Closed rammy22 closed 6 years ago

rammy22 commented 7 years ago
Could not parse file: /sample/d1de3d372d1df43cebb0869bac8e55304f1bd2d6ce925afeafd586559dde1d70
ERROR:root:Traceback (most recent call last):
  File "/.virtualenvs/macholibre/lib/python2.7/site-packages/macholibre/__init__.py", line 69, in main
    print parse(args.input[0])
  File "/.virtualenvs/macholibre/lib/python2.7/site-packages/macholibre/__init__.py", line 41, in parse
    p.parse_file()
  File "/.virtualenvs/macholibre/lib/python2.7/site-packages/macholibre/parser.py", line 814, in parse_file
    endi=identity[1], size=self.get_file_size()))
  File "/.virtualenvs/macholibre/lib/python2.7/site-packages/macholibre/parser.py", line 753, in parse_macho
    self.parse_syms(macho)
  File "/.virtualenvs/macholibre/lib/python2.7/site-packages/macholibre/parser.py", line 185, in parse_syms
    sym = Symbol(index=index, pext=pext, sym_type=n_type,
UnboundLocalError: local variable 'n_type' referenced before assignment
aaronst commented 6 years ago

This is now fixed. The part of the mach-o containing the symbol and string tables is packed. I added an entropy check to handle this.