Closed mihkelraba closed 4 months ago
Do you get the same result if the buffer contains the entire file? In general you can't guaruntee that all the metadata used by the ELF parser is in the first 2k. Note this is functionality of libmagic and not python-magic specifically.
Yes, with full file as well. With different files also.
Using file
command from cli it works correctly.
Its not the library underneath, it is from_buffer
function as you can see from the example from_file
returns correct result.
Sometimes libmagic just behaves differently in from_buffer and from_file, even if the content are identical. I think there's some features that only trigger if it gets a file descriptor.
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