php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59913 different results from finfo_file and finfo_buffer
Submitted: 2011-08-28 11:23 UTC Modified: 2016-12-04 04:22 UTC
Votes:9
Avg. Score:4.9 ± 0.3
Reproduced:8 of 8 (100.0%)
Same Version:2 (25.0%)
Same OS:2 (25.0%)
From: di_herbert dot huber at yahoo dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.3.5 OS: WinXP HE2002 SP2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-08-28 11:23 UTC] di_herbert dot huber at yahoo dot com
Description:
------------
different results from finfo_file and finfo_buffer

Scenario:
1. MS Excel-File stored in mySQL database LONGBLOB-Column
2. This binary data selected from database
3. This binary data stored to tempfile
4. mime-type sniffing done by finfo_buffer on binary data
   > result: application/octet-stream
5. mime-type sniffing done by finfo_file on tempfile
   > result: application/vnd.ms-excel

PROBLEM:
different result, dependent on used Fileinfo Function

Comment: The tempfile has NO extension like ".xls" that could be used as hint for mimetype-sniffing


Reproduce code:
---------------
<?PHP
...
      $tempFileName   = tempnam(sys_get_temp_dir(), "tempfile");
      $tempFileHandle = fopen($tempFileName, "w");
      fwrite($tempFileHandle, $attrib);
      fclose($tempFileHandle);
      // ensure that "extension=php_fileinfo.dll" is enabled in php.ini
      $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
      $fileContentsTypeBuf = finfo_buffer($finfo, $attrib, FILEINFO_MIME_TYPE);
      $fileContentsType = finfo_file($finfo, $tempFileName);
      finfo_close($finfo);
...

Expected result:
----------------
same result "application/vnd.ms-excel", independent from used Fileinfo Function (finfo_buffer or finfo_file)


Actual result:
--------------
different results 
"application/octet-stream" for finfo_buffer
"application/vnd.ms-excel" for finfo_file


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-24 14:55 UTC] ab@php.net
-Status: Open +Status: Feedback -Package: Fileinfo +Package: *General Issues
 [2016-11-24 14:55 UTC] ab@php.net
Long ago, still the exact file would be needed, to reproduce and fix the bug.

Thanks.
 [2016-12-04 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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC