macholibre icon indicating copy to clipboard operation
macholibre copied to clipboard

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfd in position 3: invalid start byte

Open LubosD opened this issue 5 years ago • 5 comments

This happens to me when I try to parse a core dump Mach-O file:

$ macholibre core.16057 
Traceback (most recent call last):
  File "/home/lubos/.local/bin/macholibre", line 11, in <module>
    load_entry_point('macholibre==1.0', 'console_scripts', 'macholibre')()
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/__init__.py", line 70, in main
    print(dumps(parse(args.input[0])))
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/__init__.py", line 45, in parse
    return parser.parse()
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/parser.py", line 1680, in parse
    self.parse_file()
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/parser.py", line 1671, in parse_file
    self.parse_macho(0, self.__output['size'])
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/parser.py", line 1588, in parse_macho
    self.parse_lcs(offset, size, nlcs, slcs)
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/parser.py", line 791, in parse_lcs
    self.parse_segment(offset, size, cmd, cmd_size))
  File "/home/lubos/.local/lib64/python3.6/site-packages/macholibre/parser.py", line 230, in parse_segment
    name = self.__file.read(16).decode().rstrip('\u0000')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfd in position 3: invalid start byte

LubosD avatar Aug 27 '18 13:08 LubosD

@LubosD thanks for the info, I'll take a look.

aaronst avatar Aug 27 '18 14:08 aaronst

Adding to this issue -- I'm experiencing a similar (the same?) error when using the package.

 Traceback (most recent call last):
   File "[redacted]", line 237, in [redacted]
     [redacted]
   File "[redacted]", line 26, in [redacted]
     macho_dictionary = macholibre.parse(f.name)
   File "/usr/local/lib/python3.6/dist-packages/macholibre/__init__.py", line 45, in parse
     return parser.parse()
   File "/usr/local/lib/python3.6/dist-packages/macholibre/parser.py", line 1680, in parse
     self.parse_file()
   File "/usr/local/lib/python3.6/dist-packages/macholibre/parser.py", line 1671, in parse_file
     self.parse_macho(0, self.__output['size'])
   File "/usr/local/lib/python3.6/dist-packages/macholibre/parser.py", line 1588, in parse_macho
     self.parse_lcs(offset, size, nlcs, slcs)
   File "/usr/local/lib/python3.6/dist-packages/macholibre/parser.py", line 791, in parse_lcs
     self.parse_segment(offset, size, cmd, cmd_size))
   File "/usr/local/lib/python3.6/dist-packages/macholibre/parser.py", line 230, in parse_segment
     name = self.__file.read(16).decode().rstrip('\u0000')
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x99 in position 14: invalid start byte

jshlbrd avatar Apr 03 '19 04:04 jshlbrd

@jshlbrd , do you have a hash I can use to test?

aaronst avatar May 09 '19 21:05 aaronst

@aaronst yep, try this one: be55e8952a262d0e524239dbf82191ed

jshlbrd avatar May 24 '19 17:05 jshlbrd

@aaronst I attempted a fix on python2 branch here: https://github.com/aaronst/macholibre/pull/28

Happyholic1203 avatar Nov 13 '19 07:11 Happyholic1203