Bug #71562 [Opn]: fileinfo cannot load distro-provided magic files

From: Date: Wed, 10 Feb 2016 11:07:25 +0000
Subject: Bug #71562 [Opn]: fileinfo cannot load distro-provided magic files
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199146@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71562&edit=1 ID: 71562 Updated by: pajoye@php.net Reported by: david dot nielson at cpanel dot net Summary: fileinfo cannot load distro-provided magic files Status: Open Type: Bug Package: Filesystem function related Operating System: Debian Sid; CentOS 6; CentOS 7 PHP Version: 7.0.3 -Assigned To: +Assigned To: remi Block user comment: N Private report: N New Comment: Remi, could you take a look please? Previous Comments: ------------------------------------------------------------------------ [2016-02-09 21:06:44] david dot nielson at cpanel dot net Description: ------------ Steps to reproduce: - Download and compile PHP 7.0.3 from php.net - Edit attached script to point to the magic file on your system (comments should help) - run script through PHP 7 binary - observe unhandled exception - run script through PHP 5.x - observe success messages Additional information: using strace, I determined that PHP is opening and reading at least some data from the magic file before throwing an exception. I could not see any information from strace to indicate what the problem might be, though. The exception doesn't say *why* the file couldn't be loaded, and I don't know how I would get more information about the nature of the exception. All I can prove is that it's not ENOENT. Test script: --------------- <?php // http://us3.php.net/manual/en/book.fileinfo.php // CentOS keeps its magic file here $magic_file = '/usr/share/misc/magic'; // Debian keeps its magic file here $magic_file = '/usr/share/file/magic'; $finfo = new finfo(FILEINFO_MIME, $magic_file); if($finfo) { echo "0 fileinfo: create finfo object\n"; } else { echo "1 fileinfo: create finfo object failed\n"; die; } $type = $finfo->file(__FILE__); if($type) { echo "0 fileinfo: read file type: $type\n"; } else { echo "1 fileinfo: read file type failed\n"; } ?> Expected result: ---------------- Running the script through PHP 5.x returns: 0 fileinfo: create finfo object 0 fileinfo: read file type: text/x-php; charset=us-ascii Actual result: -------------- 0 fileinfo: extension is loaded Fatal error: Uncaught Exception: finfo::finfo(): Failed to load magic database at '/home/david/code/php/magic'. in /home/david/code/php/php_module_fileinfo.php:35 Stack trace: #0 /home/david/code/php/php_module_fileinfo.php(35): finfo->finfo(1040, '/home/david/cod...') #1 {main} thrown in /home/david/code/php/php_module_fileinfo.php on line 35 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71562&edit=1

« previous php.bugs (#199146) next »