|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67761 Phar::mapPhar fails for Phars inside a path containing ".tar"
Submitted: 2014-08-04 17:58 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: kostik dot lv at gmail dot com Assigned:
Status: Closed Package: PHAR related
PHP Version: 5.4.31 OS: Windows, Linux
Private report: No CVE-ID: None
 [2014-08-04 17:58 UTC] kostik dot lv at gmail dot com
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:

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:

$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


require 'phar://test.phar/test.php';



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


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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-30 12:46 UTC]
Automatic comment on behalf of mike
Log: fix bug #67761
 [2015-03-30 12:46 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 11 07:01:31 2023 UTC