You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
With the Python bindings, using either lief.parse or lief.MachO.parse to parse file objects (as opposed to filenames) results in incorrect parse results.
importliefprint("lief.parse by filename:")
print(lief.parse("bugtest.so"))
print("lief.parse by object:")
print(lief.parse(open("bugtest.so", "rb")))
print("lief.MachO.parse by object:")
print(lief.MachO.parse(open("bugtest.so", "rb")))
Expected behavior
These three parses should produce identical outputs.
Observed behavior
The three parses produce wildly different results: logs.zip.
lief.parse(filename) produces a reasonable-looking parse of the file.
lief.parse(fileobj) produces a total mess: 4096 Unknown architecture messages, followed by a header that indicates 4096 commands, followed by one UNIXTHREAD command and 4095 THREAD commands which all have flavor=0x65745f5f, count=0x7478, pc=0x000000. In short: a completely broken parse, as if it's failing to properly advance the file pointer while reading the file.
lief.MachO.parse(fileobj) produces almost the same output as lief.parse(filename), except that the Binding Info and Export Info are missing from the DYLD_INFO_ONLY command. Unfortunately, the bindings are simply not parsed at all (bin.dyld_info.bindings is empty).
Environment:
macOS 14.6.1 (Intel), Python 3.10.11, lief 0.15.1
Tested in a virtual environment with only lief installed
Also tested with lief 0.16.0-ba294bd1, bug exists there too
Have verified that the bug is not apparently present with ELF or PE (haven't tested in depth though).
The text was updated successfully, but these errors were encountered:
Describe the bug
With the Python bindings, using either
lief.parse
orlief.MachO.parse
to parse file objects (as opposed to filenames) results in incorrect parse results.To Reproduce
Steps to reproduce the behavior:
Expected behavior
These three parses should produce identical outputs.
Observed behavior
The three parses produce wildly different results: logs.zip.
lief.parse(filename)
produces a reasonable-looking parse of the file.lief.parse(fileobj)
produces a total mess: 4096Unknown architecture
messages, followed by a header that indicates 4096 commands, followed by oneUNIXTHREAD
command and 4095THREAD
commands which all haveflavor=0x65745f5f, count=0x7478, pc=0x000000
. In short: a completely broken parse, as if it's failing to properly advance the file pointer while reading the file.lief.MachO.parse(fileobj)
produces almost the same output aslief.parse(filename)
, except that the Binding Info and Export Info are missing from theDYLD_INFO_ONLY
command. Unfortunately, the bindings are simply not parsed at all (bin.dyld_info.bindings
is empty).Environment:
The text was updated successfully, but these errors were encountered: