Bug #81426 [Asn->Nab]: Regression in finfo_open
Edit report at https://bugs.php.net/bug.php?id=81426&edit=1
ID: 81426
Updated by: ab@php.net
Reported by: weierophinney@php.net
Summary: Regression in finfo_open
-Status: Assigned
+Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: Ubuntu 20.04
PHP Version: 8.1.0RC1
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Thanks for the report and further investigation. There are no guarantees on the magic data format
compatibility whatsoever. A general recommendation is to omit usage of an external magic data.
Thanks
Previous Comments:
------------------------------------------------------------------------
[2021-09-08 23:04:33] ramsey@php.net
I did a little digging around to see where this issue might have been introduced. We ported libmagic
to 5.40 in 8.1, and I wonder if this might have introduced a regression: https://github.com/php/php-src/commit/3b9173dc8f3bda99e87003f6b6b2a16fa25c1b72
------------------------------------------------------------------------
[2021-09-08 21:24:32] weierophinney@php.net
Description:
------------
When supplying a MAGIC file to finfo_open, valid MAGIC files that were parsed correctly in PHP 7.3 -
8.0 now result in parse errors within the finfo extension.
An example of a MAGIC file that was working previously: https://raw.githubusercontent.com/laminas/laminas-validator/2.15.x/test/File/_files/magic.7.mime
The above file has been used in unit tests since the 5.6 series without issue; we only began seeing
the issues when attempting to test against PHP 8.1rc1.
Test script:
---------------
$finfo = finfo_open(FILEINFO_MIME_TYPE, 'magic.7.mime'); // file referenced in Description
section
echo finfo_file($finfo, 'plain.txt'); // assuming plain.txt is a text file
Expected result:
----------------
text/plain; charset=us-ascii
Actual result:
--------------
PHP Warning: finfo_open(): Unparsable number `a \b C.S0050-0 V1.0' in php shell
code on line 1
Warning: finfo_open(): Unparsable number `a \b C.S0050-0 V1.0' in php shell code on
line 1
PHP Warning: finfo_open(): Unparsable number `b \b C.S0050-0-A V1.0.0' in php
shell code on line 1
Warning: finfo_open(): Unparsable number `b \b C.S0050-0-A V1.0.0' in php shell
code on line 1
PHP Warning: finfo_open(): Unparsable number `c \b C.S0050-0-B V1.0' in php
shell code on line 1
Warning: finfo_open(): Unparsable number `c \b C.S0050-0-B V1.0' in php shell code
on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line
1
Warning: finfo_open(): Unparsable number `\b, contains[@0x%x]: ' in php shell code on line 1
PHP Warning: finfo_open(): Unparsable number `\b: ' in php shell code on line 1
Warning: finfo_open(): Unparsable number `\b: ' in php shell code on line 1
PHP Warning: finfo_open(): Overflow for numeric type `leshort' value 0x223e9f78 in php shell
code on line 1
Warning: finfo_open(): Overflow for numeric type `leshort' value 0x223e9f78 in php shell code
on line 1
PHP Warning: finfo_open(): `name pgpkey' entries can only be declared at top level in
php shell code on line 1
Warning: finfo_open(): `name pgpkey' entries can only be declared at top level in php shell
code on line 1
PHP Warning: finfo_open(): Unparsable number `\b number=%d' in php shell code on line 1
Warning: finfo_open(): Unparsable number `\b number=%d' in php shell code on line 1
PHP Warning: finfo_open(): Failed to load magic database at "magic.7.mime" in php shell
code on line 1
Warning: finfo_open(): Failed to load magic database at "magic.7.mime" in php shell code
on line 1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81426&edit=1
Thread (3 messages)