php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67556 finfo_open does not work with phar:// magic files
Submitted: 2014-07-02 20:01 UTC Modified: 2018-08-21 12:15 UTC
From: cweiske@php.net Assigned:
Status: Open Package: PHAR related
PHP Version: 5.6.0RC1 OS: Ubuntu Linux 13.10
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
3 + 14 = ?
Subscribe to this entry?

 
 [2014-07-02 20:01 UTC] cweiske@php.net
Description:
------------
Packing a magic file into a phar and using finfo_open(0, 'phar://test.phar/file.magic'); does not work.

Try to create the .phar with the generator script and run it. It will fail.

Test script:
---------------
<?php
$phar = new Phar('test.phar');
$phar->addFromString('test.magic', <<<'MGC'
0       string             =<?php         PHP text
!:mime  text/x-php
MGC
);
$phar->setStub(<<<'PHP'
<?php
$finfo = finfo_open(0, 'phar://' . __FILE__ . '/test.magic');
__HALT_COMPILER();
?>
PHP
);
?>


Expected result:
----------------
no error.

Actual result:
--------------
$ php-5.6.0RC1 test.phar 
PHP Warning:  finfo_open(/tmp/test/phar): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2

Warning: finfo_open(/tmp/test/phar): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2
PHP Warning:  finfo_open(/tmp/test/phar): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2

Warning: finfo_open(/tmp/test/phar): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2
PHP Warning:  finfo_open(/tmp/test/test.phar/test.magic): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2

Warning: finfo_open(/tmp/test/test.phar/test.magic): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2
PHP Notice:  finfo_open(): Warning: using regular magic file `/tmp/test/test.phar/test.magic' in /tmp/test/test.phar on line 2

Notice: finfo_open(): Warning: using regular magic file `/tmp/test/test.phar/test.magic' in /tmp/test/test.phar on line 2
PHP Warning:  finfo_open(/tmp/test/test.phar/test.magic): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2

Warning: finfo_open(/tmp/test/test.phar/test.magic): failed to open stream: No such file or directory in /tmp/test/test.phar on line 2
PHP Warning:  finfo_open(): Failed to load magic database at '/tmp/test/phar:/tmp/test/test.phar/test.magic'. in /tmp/test/test.phar on line 2

Warning: finfo_open(): Failed to load magic database at '/tmp/test/phar:/tmp/test/test.phar/test.magic'. in /tmp/test/test.phar on line 2


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-21 11:11 UTC] cmb@php.net
To my knowledge, finfo_open() does not support any stream wrappers
at all.
 [2018-08-21 12:15 UTC] requinix@php.net
Yeah, doesn't look like libmagic has support for some sort of custom database. It wants filenames.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 13:01:27 2019 UTC