|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49732 PHP crashes when using finfo_file() to get mime info with this file (included)
Submitted: 2009-10-01 07:27 UTC Modified: 2009-10-01 15:30 UTC
From: nirvn dot asia at gmail dot com Assigned: pajoye (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.0 OS: windows xp
Private report: No CVE-ID: None
 [2009-10-01 07:27 UTC] nirvn dot asia at gmail dot com
Using the function finfo_file() to get the mime of the file attached to this bug will crash PHP (and apache) on windows XP / 2003. I didn't have the chance to test it on a linux machine. 

Reproduce code:
//here's the code that goes kaboom
$finfo = finfo_open(FILEINFO_MIME); 
$mime = finfo_file($finfo,realpath($fname));

Expected result:
Returns the mime type of desired file.

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-01 07:51 UTC] nirvn dot asia at gmail dot com
Hrm, I didn't know we can't attach files to bug reports. I've uploaded it to our NGO website for easy access to any developer who would like to help resolving this bug.

$fname =

I've also attached the basic debug info that XP outputs when it crashes, you can access it from
 [2009-10-01 09:21 UTC]
Can you post a link to the file or drop me a mail with the file attached please?

Please also try using a 5.3 snapshot (
 [2009-10-01 09:22 UTC]
I got the mail later, but you can still try with a snapshot :)
 [2009-10-01 09:42 UTC] nirvn dot asia at gmail dot com
I've just downloaded a 5.3 snapshot from the link provided and confirm it still crashes PHP.

Pajoye, thanks for the quick answer, it's appreciated.
 [2009-10-01 10:25 UTC]
Ok, I have a fix for at least the crash but I'm not sure we can fix the detection failure.

Can you create a small word document in Word (cambodia version or the language you used) please? I would like to see if it is the "kaboom.doc" that is corrupt or if there is something different in the format for this version of Word.

Check if timestamp conversion failed:
 [2009-10-01 12:09 UTC] nirvn dot asia at gmail dot com
Having a fix for the crash would be fantastic, never mind the detection failure if it's too  hard. We're doing batch processing of files and extract plain text of types we support (doc/pdf/rdf/etc.). With this crash, the process breaks and thus leaves many files unchecked for extraction.

Regarding the kaboom.doc, if you open it in word and save it as new file, the crash disappear (hence the reason why I'm dragging along this bug a 3meg testcase :) )

Pajoye, I'm unsure what you want me to do with the timestamps conversion bit.

Once again, thanks for the prompt response and time spent on this.
 [2009-10-01 13:55 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - fix #49732, fix crash when timestamp conversion fails
 [2009-10-01 13:55 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Next snapshots will have the fix.
 [2009-10-01 15:30 UTC] nirvn dot asia at gmail dot com
Pajoye, this must be the nicest interaction I had with reporting a bug against a product, thanks a lot.
 [2009-10-09 14:51 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - Merge: Fix #49732, Crashes in fileinfo when corrupted files are given (timestamp fails)
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 07:05:46 2022 UTC