Bug 758429

Summary: file command incorrectly identifies a JPEG file as being a Minix filesystem
Product: Red Hat Enterprise Linux 5 Reporter: Alan Staples <alan.staples>
Component: fileAssignee: Jan Kaluža <jkaluza>
Status: CLOSED ERRATA QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: low Docs Contact:
Priority: low    
Version: 5.5CC: ksrot, mmalik, ovasik
Target Milestone: rc   
Target Release: 5.5   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Minix magic pattern has the same beginning as the JPEG magic pattern and File tries to match Minix magic pattern before JPEG. Consequence: This causes some JPEG files are detected as Minix filesystem. Fix: Order of JPEG and Minix magic patterns have been changed, because JPEG magic pattern is longer and therefore stronger. Result: File now tries to match JPEG magic pattern before Minix magic pattern, so it detects JPEG files properly.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 05:46:40 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 771700, 772019    
Attachments:
Description Flags
2 JPEG image files - 1 normal and 1 that causes this issue
none
proposed patch none

Description Alan Staples 2011-11-29 19:25:25 UTC
Created attachment 538200 [details]
2 JPEG image files - 1 normal and 1 that causes this issue

Description of problem:
The "file" utility incorrectly identifies a JPEG file as being of type "Minix filesystem"

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 5 Update 5 64-bit
file-4.17-15.el5_3.1

How reproducible:
consistently, but only for some JPEG files

Steps to Reproduce:
1. extract the attached "jpeg_examples.tgz" file
2. copy extracted files to /tmp 
2. execute "file /tmp/funky.jpeg"
  
Actual results:
The utility outputs: "Minix filesystem, 30 char names"

Expected results:
The utility outputs: "JPEG image data, JFIF standard 1.01"

Additional info:
I've also included a "normal.jpeg" file within the attachment, which I have generated the same way as the attached "funky.jpeg", yet the file command works as expected on this JPEG.

Comment 2 Jan Kaluža 2011-11-30 08:27:06 UTC
Created attachment 538461 [details]
proposed patch

Check JPEG before minix FS since JPEG pattern is stronger

Comment 5 Alan Staples 2011-12-01 14:40:25 UTC
(In reply to comment #2)
> Created attachment 538461 [details]
> proposed patch
> 
> Check JPEG before minix FS since JPEG pattern is stronger

I tried "file -k" and indeed this does identify that the file is either a "Minix file system" or "JPEG image data, JFIF standard 1.01". I can parse the output of this command for "JPEG image data" systematically now. Thank you for your help.

Comment 10 Jan Kaluža 2012-01-05 11:37:44 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: Minix magic pattern has the same beginning as the JPEG magic pattern and File tries to match Minix magic pattern before JPEG.

Consequence: This causes some JPEG files are detected as Minix filesystem.

Fix: Order of JPEG and Minix magic patterns have been changed, because JPEG magic pattern is longer and therefore stronger.

Result: File now tries to match JPEG magic pattern before Minix magic pattern, so it detects JPEG files properly.

Comment 11 errata-xmlrpc 2012-02-21 05:46:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0201.html