Bug 980507 - magic_file() detects bad mimetype for compressed files
magic_file() detects bad mimetype for compressed files
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: file (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jan Kaluža
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-02 10:37 EDT by Tomas Mlcoch
Modified: 2013-07-03 06:41 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-03 06:41:11 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Reproducer (1.08 KB, application/x-shellscript)
2013-07-02 10:37 EDT, Tomas Mlcoch
no flags Details

  None (edit)
Description Tomas Mlcoch 2013-07-02 10:37:13 EDT
Created attachment 767791 [details]
Reproducer

Description of problem:

magic_file() detects "application/octet-stream; charset=binary"
instead of "application/x-gzip; charset=binary" for gzip, "application/x-bzip2; charset=binary" for bzip and "application/x-xz; charset=binary" for xz.
For text files detection works fine.
No other file types tested.

Version-Release number of selected component (if applicable):
Name        : file
Arch        : i686
Version     : 5.14
Release     : 9.fc20

How reproducible:
always

Steps to Reproduce:
Reproducer appended

Actual results:
application/x-xz; charset=binary for every tested compressed file.
Comment 1 Jan Kaluža 2013-07-03 01:59:46 EDT
It looks like in File-5.14, magic_check/magic_load/magic_compile/magic_list are mutual exclusive. If you use magic_load(), it loads magic patterns from file and you can use them later, but if you call magic_check(), it will reload the patterns, check them and free them. So next magic_* functions will not return sane value, because magic patterns are not loaded (they have been freed by magic_check function).

Solution could be calling magic_check before magic_load (I've tested it and it works).

I'm not sure it's the good decision to change behaviour like this and I will raise it upstream, but we have to stay consistent with upstream in question of API semantics.
Comment 2 Tomas Mlcoch 2013-07-03 06:21:33 EDT
Hi, I've thrown magic_check() away. Probably, it has been useless for my usage anyway (I've always load a default mime-type db).
All createrepo_c unittest are green now.
Thank you.
Comment 3 Jan Kaluža 2013-07-03 06:41:11 EDT
I'm closing this bug as NOTABUG. It's intended upstream behaviour.

Note You need to log in before you can comment on or make changes to this bug.