python-magic
python-magic copied to clipboard
Bug in from_buffer function
Detecting file type with from_file and from_buffer functions give different results for the same file. From_buffer function recognizes elf binary as shared object.
OS: Ubuntu 22.04
Python 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> magic.from_buffer(open("/bin/bash", "rb").read(2048))
'ELF 64-bit LSB shared object, x86-64, version 1 (SYSV)'
>>> magic.from_file('/bin/bash')
'ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=7a6408ba82a2d86dd98f1f75ac8edcb695f6fd60, for GNU/Linux 3.2.0, stripped'