Bug #67761 [NEW]: Phar::mapPhar fails for Phars inside a path containing ".tar"
| From: | kostik dot lv at gmail dot com | Date: | Mon, 04 Aug 2014 17:58:49 +0000 |
| Subject: | Bug #67761 [NEW]: Phar::mapPhar fails for Phars inside a path containing ".tar" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186963@lists.php.net to get a copy of this message | ||
From: kostik dot lv at gmail dot com
Operating system: Windows, Linux
PHP version: 5.4.31
Package: PHAR related
Bug Type: Bug
Bug description:Phar::mapPhar fails for Phars inside a path containing ".tar"
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 bug report at https://bugs.php.net/bug.php?id=67761&edit=1
--