Bug #69214 [NEW]: Regression in libmagic magic.mime printf detection

From: Date: Tue, 10 Mar 2015 15:16:28 +0000
Subject: Bug #69214 [NEW]: Regression in libmagic magic.mime printf detection
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191289@lists.php.net to get a copy of this message
From: weierophinney Operating system: Ubuntu 14.10 PHP version: master-Git-2015-03-10 (Git) Package: Filesystem function related Bug Type: Bug Bug description:Regression in libmagic magic.mime printf detection Description: ------------ We're testing ZF2 against PHP7 nightly. In the last couple days, we started noticing that our tests that use a magic.mime file started failing, with messages of the format "finfo_open(): Warning: Printf format l' is not valid for type lequad' in description `...'". From what I can see, recent changes to ext/fileinfo/libmagic/ have removed support for the following printf sequences: * l, ll, h, and hh (used as length modifiers) * .0 (used to indicate zero-padding vs space padding) * numeric precision This is particularly problematic, as the lequad and bequad libmagic specifications require specific formats that require such modifiers, and without the above, there is no way to provide a valid magic.mime file to finfo_open(). Researching libmagic, I cannot find a magic.mime file that does NOT have these formats present. Test script: --------------- <?php $magicData = file_get_contents('https://raw.githubusercontent.com/zendframework/zf2/2750340ad353cad9e80525d1c13efcda03e21027/tests/ZendTest/Validator/File/_files/magic.mime'); $magicFile = tempnam(sys_get_temp_dir(), 'mag'); file_put_contents($magicFile, $magicData); finfo_open(FILEINFO_MIME_TYPE, $magicFile); Actual result: -------------- ErrorException: finfo_open(): Failed to load magic database at '...'. Caused by ErrorException: finfo_open(): Warning: Printf format `h' is not valid for type leshort' in description .%hd' // and many, many more similar errors -- Edit bug report at https://bugs.php.net/bug.php?id=69214&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69214&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69214&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69214&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69214&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69214&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69214&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69214&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69214&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69214&r=support Expected behavior: https://bugs.php.net/fix.php?id=69214&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69214&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69214&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69214&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69214&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69214&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69214&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69214&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69214&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69214&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69214&r=mysqlcfg

« previous php.bugs (#191289) next »