|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67647 Bundled libmagic 5.17 does not detect quicktime files correctly
Submitted: 2014-07-18 08:24 UTC Modified: 2015-01-22 11:02 UTC
From: emkael at tlen dot pl Assigned: ab (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.6.0RC2 OS: Debian 3.14.12 x86_64 GNU/Linux
Private report: No CVE-ID: None
 [2014-07-18 08:24 UTC] emkael at tlen dot pl
Version 5.6.0RC2 bundles libmagic in version 5.17.

That version, contrary to (i.e.) 5.19, fails to detect certain quicktime files as video/quicktime, and serves "binary" instead.

I've attached a series of command-line tests that replicate the issue and correlate it with libmagic version, attached below.

Unfortunately, the test does not replicate the issue with a sample MOV file from Apple's KB, but works on various other MOV files.

The offending file magic rule was commented out from the file Magdir database in February (so, it's fixed in libmagic version >= 5.18):

PS I'm not sure which packages does this issue belong to, apologies for that.

Test script:
user@machine:~$ hexdump -C | head -n 1
00000000  00 00 00 20 66 74 79 70  71 74 20 20 20 05 03 00  |... ftypqt   ...|

user@machine:~$ file -v
magic file from /etc/magic:/usr/share/misc/magic

user@machine:~$ file -b --mime-type

user@machine:~$ php -i | grep libmagic
libmagic => 517

user@machine:~$ php -r '$fi = new finfo(FILEINFO_MIME_TYPE); print($fi->file("")."\n");'

user@machine:~$ php -r '$fi = new finfo(); print($fi->file("")."\n");'
floppy with old FAT filesystem 320k, Media descriptor 0xff

user@other_machine:~$ file -v
magic file from /etc/magic:/usr/share/misc/magic

user@other_machine:~$ file -b --mime-type


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-03 12:47 UTC]
-Status: Open +Status: Feedback
 [2015-01-03 12:47 UTC]
Could you please post a minimal file to reproduce? Say cut only the furst few KB or even less that can tell the difference.

 [2015-01-03 18:35 UTC]
-Assigned To: +Assigned To: ab
 [2015-01-07 09:57 UTC] emkael at tlen dot pl
Here's the smallest I could go:

I've truncated the original file to a single frame (note that re-encoding with ffmpeg/lavf56 makes the problem go away) and overwritten actual video data with random bytes (for copyright reasons) - it's still a valid QuickTime file (apart from some warnings due to that random data), it's recognized by ffprobe/ffmpeg (as I've pasted in the gist) and produces "floppy with old FAT filesystem 320k, Media descriptor 0xff" as finfo output.

My best guess is that either the original codec omitted some header data which made the file detection fall to the weaker rule for FAT filesystem or that the FAT filesystem rule was being tested too early.

I've already worked around my specific issue by falling back to a custom magic file which detects MOV files more loosely, but since the upstream Magdir entry was reverted for being "too weak", the same problem might occur with some other, unrelated file formats.
 [2015-01-11 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2015-01-22 10:57 UTC]
Automatic comment on behalf of ab
Log: Fixed bug #67647 Bundled libmagic 5.17 does not detect quicktime files correctly
 [2015-01-22 10:57 UTC]
-Status: No Feedback +Status: Closed
 [2015-01-22 11:02 UTC]
@emkael, thanks for the test file :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Mar 04 06:01:30 2024 UTC