|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64462 Bug in libmagic included with fileinfo extension
Submitted: 2013-03-20 12:05 UTC Modified: 2013-04-07 20:51 UTC
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: vitalif at mail dot ru Assigned: ab (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.5.0alpha5 OS:
Private report: No CVE-ID: None
 [2013-03-20 12:05 UTC] vitalif at mail dot ru

First of all I want to say that libmagic included with fileinfo extension is 2 YEARS OLD and has bugs - you should UPDATE it to something like 5.13. Also it would be good if you submit your libmagic fixes to UPSTREAM (to libmagic author) - at least some of them.

And also I want to tell you about a specific bug - your libmagic detects all MSOffice documents unknown to it as "application/msword". For example, any Visio (CDF) document is detected as "application/msword", which is incorrect. This bug was in libmagic 5.11, but is already fixed in 5.13.

I would propose updating the included libmagic, but if you don't want to do it you can just apply a simple patch (attached). With it Visio and all other unknown files are detected as application/ which is more correct.


libmagic-fix-incorrect-msword-detection (last revision 2013-03-20 12:06 UTC by vitalif at mail dot ru)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-21 11:21 UTC]
Thanks for the patch. We use libmagic 5.11 which is about one year old. You're right, it could be upgraded. Most our fixes related to it are PHP specific.

It would be nice if you'd submit a testcase for this, furthermore it's essential. That will be useful now to test this patch and later after upgrade.
 [2013-03-21 11:21 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: ab
 [2013-03-21 12:36 UTC] vitalif at mail dot ru
-Status: Feedback +Status: Assigned
 [2013-03-21 12:36 UTC] vitalif at mail dot ru
For testing you should first get any Visio document, for example this one from a public SVN repository:

And then run


$o = finfo_open();
echo finfo_file($o, "testfile.vsd", FILEINFO_MIME_TYPE);

The correct output will be "application/", the incorrect will be "application/msword".
 [2013-04-07 20:51 UTC]
Just upgraded to libmagic 5.14 in PHP 5.4+ dev branches, please test.
 [2013-04-07 20:51 UTC]
-Status: Assigned +Status: Closed
 [2013-09-29 10:34 UTC] vitalif at mail dot ru
Thank you, it works in PHP 5.5!
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 19:01:28 2023 UTC