|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #57473 Be able to use magic-info from package shared-mime-info
Submitted: 2007-01-10 10:52 UTC Modified: 2017-10-11 17:17 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: motin at demomusic dot nu Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.0 RC4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
24 - 4 = ?
Subscribe to this entry?

 [2007-01-10 10:52 UTC] motin at demomusic dot nu
Fileinfo should be able to use not only the magic-file supplied by Apache or the libmagic magic-file but also the magic-info included with the package shared-mime-info from

The files currently generated by shared-mime-info's update-mime-database are stored in binary form and trying to link to any of these files as the magic file yields the error: 

finfo_open(): Failed to load magic database at '/path/to/updated/files/magic'. in ...

The same error is produced when trying any other of the updated files, as well as trying a copy of "magic" renamed to "magic.mime" (Needed for fileinfo ta accept the /etc/apache2/magic file earlier)

Using the shared-mime-info magic-info would allow fileinfo to detect a lot more mimetypes more exactly.

Reproduce code:
$finfo = finfo_open(FILEINFO_MIME, "/path/to/updated/files/magic");

Expected result:
No errors, fileinfo object loading successsfully ready to be used.

Actual result:
finfo_open(): Failed to load magic database at '/path/to/updated/files/magic'. in ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-04 10:47 UTC] joungkyun at gmail dot com
if /path/to/updated/files/magic is soft link, fix it follow patch. This is clearly bug. :-( I want to fix it.

diff -urNp fileinfo/fileinfo.c
--- 2006-11-08 06:18:51.000000000 +0900
+++ fileinfo/fileinfo.c 2007-10-04 23:22:43.000000000 +0900
@@ -260,12 +260,12 @@ PHP_FUNCTION(finfo_open)

-   if (file_len) { /* user specified filed, perform open_basedir checks */
-       if (!VCWD_REALPATH(file, resolved_path)) {
-           RETURN_FALSE;
-       }
-       file = resolved_path;
+   if (!VCWD_REALPATH(file, resolved_path)) {
+   }
+   file = resolved_path;

+   if (file_len) { /* user specified filed, perform open_basedir checks */
        if ((PG(safe_mode) && (!php_checkuid(file, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(file TSRMLS_CC)) {
 [2017-07-04 07:23 UTC] motin at demomusic dot nu
Please close this ancient and inaccurate bug report, I've lost the password. 

(This works as it should nowadays and may have worked a decade ago, when I first reported the bug, but was a lot less experienced :) )
 [2017-10-11 17:17 UTC]
-Status: Open +Status: Not a bug -Package: Fileinfo +Package: *General Issues
 [2017-10-11 17:17 UTC]
Closing as per request. But also to mention is - external magic files are versioned, so loading some version not matching current ext version won't work.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 14:01:28 2024 UTC