Closed tgs closed 10 months ago
Thanks for the report! The library is supposed to return null for an error here, and then we fetch the message with magic_error
.
This sounds like a regression in libmagic, could you file it here?
Huh, looking at it from their perspective, they probably consider it a feature...
The magic_file() function returns a textual description of the
contents of the filename argument, or NULL if an error occurred.
If the filename is NULL, then stdin is used.
"if an error occurred" - not "if the file is erroneous"
Thank you for taking a look!
In my application, we use
Magic(uncompress=True)
to detect corrupted gzip files. On CentOS 7, this code behaves as expected, raising aMagicException
:->
magic.MagicException: b'zlib: invalid stored block lengthsapplication/x-empty compressed-encoding=application/x-gzip; charset=binary; charset=binary'
However, on AlmaLinux 8, it seems to just return a string holding an error message:
'zlib ERROR: invalid stored block lengths compressed-encoding=application/x-gzip; charset=binary'
Both are running python-magic 0.4.27
Versions of libmagic - let me know if this isn't enough detail CentOS7 has file-libs-5.11-37.el7.x86_64 - works Alma8 has file-libs-5.33-24.el8.x86_64 - doesn't work
Thanks for a super useful library, we'd appreciate any help you can give!