[File] [PATCH] Fix broken BMP detection since 5.38

Huki gk7huki at gmail.com
Sat Feb 1 22:52:49 UTC 2020


Since updating to File 5.38, bitmap images with header size 40 (Windows 
3.x format) aren't detected under certain conditions. It seems to happen 
when the file size is > 1MB (eg, a 1024 x 1024 RGB image).

$ file test.bmp
test.bmp: data

I traced down the issue to this recently added line:

# jump 4 bytes before end of file/header to skip 
fmt-116-signature-id-118.dib
 >>(2.l-4)    ulong    x        PC bitmap, Windows 3.x format

It's a bit weird and I don't see any reason to do this. I removed this 
(and adjusted the lines below) and the detection is working again.

$ file -m magic.mgc test.bmp
test.bmp: PC bitmap, Windows 3.x format, 1024 x 1024 x 24, image size 
3145728, resolution 11811 x 11811 px/m, cbSize 3145782, bits offset 54

Also, I changed the mimetype to consistently use image/x-ms-bmp as 
opposed to image/bmp in some places.
I've attached the patch and the test bitmap file.

Regards,
Huki

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.bmp.gz
Type: application/gzip
Size: 28789 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200202/10efefd4/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-patch
Size: 4103 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200202/10efefd4/attachment-0003.bin>


More information about the File mailing list