View Issue Details

IDProjectCategoryView StatusLast Update
0000622fileGeneralpublic2025-02-07 18:46
ReporterOdd_Bloke Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version5.46 
Summary0000622: Incorrect mime type for zip files when using magic_buffer
DescriptionUsing `python3-magic` as the interface, `magic.from_buffer(..., mime=True)` against a zip file with libmagic 5.45 installed returns the expected `application/zip` but with libmagic 5.46 installed returns `application/octet-stream` instead.

Note that unlike https://bugs.astron.com/view.php?id=612, the `file` command does return the expected `application/zip` with both library versions. The issue I'm hitting does sound like the issue ifoancea mentioned in the first comment on that issue.
Steps To ReproduceUsing Docker to reproduce with 5.46 (with irrelevant output redacted for readability):

$ docker run -t cgr.dev/chainguard/wolfi-base sh -c '
    apk add file libmagic py3-magic python3 zip
    touch test_file
    zip test.zip test_file
    file --mime test.zip
    python3 -c "import magic; file = open(\"test.zip\",\"rb\"); print(magic.from_buffer(file.read(), mime=True))"'
fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz
(1/18) Installing libmagic (5.46-r1)
(2/18) Installing file (5.46-r1)
...
OK: 69 MiB in 33 packages
  adding: test_file (stored 0%)
test.zip: application/zip; charset=binary
application/octet-stream

and to see the expected behaviour on the previous version (note the version specifiers on the file and libmagic packages):

$ docker run -t cgr.dev/chainguard/wolfi-base sh -c '
    apk add file\<5.46 libmagic\<5.46 py3-magic python3 zip
    touch test_file
    zip test.zip test_file
    file --mime test.zip
    python3 -c "import magic; file = open(\"test.zip\",\"rb\"); print(magic.from_buffer(file.read(), mime=True))"'
fetch https://packages.wolfi.dev/os/x86_64/APKINDEX.tar.gz
(1/18) Installing libmagic (5.45-r4)
(2/18) Installing file (5.45-r4)
...
OK: 67 MiB in 33 packages
  adding: test_file (stored 0%)
test.zip: application/zip; charset=binary
application/zip
Additional Information(I have also tested a build of master from GitHub and observed the same unexpected behaviour.)
TagsNo tags attached.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2025-02-07 18:46 Odd_Bloke New Issue