Bug #67761 [Opn->Csd]: Phar::mapPhar fails for Phars inside a path containing ".tar"
| From: | mike@php.net | Date: | Mon, 30 Mar 2015 12:46:27 +0000 |
| Subject: | Bug #67761 [Opn->Csd]: Phar::mapPhar fails for Phars inside a path containing ".tar" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-191720@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67761&edit=1
ID: 67761
Updated by: mike@php.net
Reported by: kostik dot lv at gmail dot com
Summary: Phar::mapPhar fails for Phars inside a path
containing ".tar"
-Status: Open
+Status: Closed
Type: Bug
Package: PHAR related
Operating System: Windows, Linux
PHP Version: 5.4.31
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8f7e378b9f2fb4f2bb5605d9440d7d34bee6978a
Log: fix bug #67761
Previous Comments:
------------------------------------------------------------------------
[2014-08-04 17:58:48] kostik dot lv at gmail dot com
Description:
------------
If you trying to run a phar file from a directory which path contains ".tar" inside, it
fails.
To reproduce, create a simple phar with the attached test script, and then:
mkdir blah.tar-blah
cp test.phar ./blah.tar-blah/
And try running:
php ./blah.tar-blah/test.phar
The bug is most probably caused by this line: http://lxr.php.net/xref/PHP_5_4/ext/phar/tar.c#116
It's funny that I came across this when one of my colleagues was unable to run
'composer.phar' on our new server. The home directories are using lower-cased
"first.last" naming pattern there and the colleague happened to have a last name starting
with Tar :) It took a while to figure out that you can't run Phars if you last name starts with
Tar :)
Test script:
---------------
<?php
$phar = new Phar('test.phar');
$phar->addFromString('test.php', '<?php echo "Test";');
$longFile = str_repeat("# just some dummy stuff\n", 500);
$phar->addFromString('some.txt', $longFile);
$stub = <<<'EOF'
#!/usr/bin/env php
<?php
Phar::mapPhar('test.phar');
require 'phar://test.phar/test.php';
__HALT_COMPILER();
EOF;
$phar->setStub($stub);
Expected result:
----------------
"Test" being output
Actual result:
--------------
PHP Fatal error: Uncaught exception 'PharException' with message 'phar error:
"/root/blah.tar-blah/test.phar" is a corrupted tar file (checksum mismatch of file
"#!/usr/bin/env php
<?php
Phar::mapPhar('test.phar');
require 'phar://test.phar/test.php';
__HALT_")' in /root/blah.tar-blah/test.phar:4
Stack trace:
#0 /root/blah.tar-blah/test.phar(4): Phar::mapPhar('test.phar')
#1 {main}
thrown in /root/blah.tar-blah/test.phar on line 4
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67761&edit=1