|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64343 PharData::extractTo fails for tarball created by BSD tar
Submitted: 2013-03-03 19:52 UTC Modified: 2015-03-30 11:51 UTC
Avg. Score:4.8 ± 0.5
Reproduced:8 of 12 (66.7%)
Same Version:6 (75.0%)
Same OS:6 (75.0%)
From: njh at aelius dot com Assigned: mike (profile)
Status: Closed Package: PHAR related
PHP Version: 5.4.12 OS: Mac OS 10.7.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: njh at aelius dot com
New email:
PHP Version: OS:


 [2013-03-03 19:52 UTC] njh at aelius dot com
The extractTo() method in Phar doesn't seem to work with tar archives generated 
using the BSD version of the tar tool, which is the version that comes pre-
installed on Mac OS X.

I have uploaded two sample tar files, which both contain a single test.txt file:

When run the GNU generated tar file works correctly but the BSD generated tar 
file fails.

This problem came up with trying to install dependencies using composer, that 
had been generated using BSD tar on Mac OS X:

Test script:
  $phar = new PharData('test-gnu.tar.gz');

  $phar = new PharData('test-bsd.tar.gz');

Expected result:
Both the test-bsd.tar.gz and test-gnu.tar.gz should extract the test.txt file.

Actual result:
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'phar 
error: "/tmp/tartest/test-bsd.tar.gz" is a corrupted tar file (checksum mismatch 
of file "18 uid=1451698731
20 ctime=1362335175
20 atime=1362335267
23 SCHILY.ino=1224")' in /tmp/tartest/test.php:5
Stack trace:
#0 /tmp/tartest/test.php(5): PharData->__construct('test-bsd.tar.gz')
#1 {main}
  thrown in /tmp/tartest/test.php on line 5


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-05 16:53 UTC]
-Assigned To: +Assigned To: ralphschindler
 [2013-03-05 16:53 UTC]
How did you create these tar files?  On mac (10.8.2), I did:

tar cvf my-bsd.tar test.txt

This created a ustar format tar file.  Yours seems to be a pax format tar file, which I can't see how that is the default format on mac?
 [2013-03-08 11:10 UTC] njh at aelius dot com
This is the version of tar that comes with Mac OS 10.7.5:

~ $ /usr/bin/tar --version
bsdtar 2.8.3 - libarchive 2.8.3

Files were created using:
tar -zcvf test-bsd.tar.gz test.txt

I have double checked and it indeed creates the PAX format by default, However 
man page does not make this clear:

When forcing to the ustar format:
tar --format ustar -zcvf test-bsd-ustar.tar.gz test.txt

Then PharData::extractTo works correctly.
 [2013-03-08 11:24 UTC] njh at aelius dot com
I didn't previously notice that the documentation says that only the 'ustar' 
format is supported:

Perhaps the resolution of this bug is to display a better error message when 
trying to extract the pax format?
 [2015-03-29 07:08 UTC]
-Assigned To: ralphschindler +Assigned To: mike
 [2015-03-29 07:08 UTC]
I have a fix in the pipe.
 [2015-03-30 11:51 UTC]
-Status: Assigned +Status: Closed
 [2015-03-30 11:51 UTC]
Fixed in d380d1cb1ba48c41682f749692b78a10e91dd070 (5.5.24+)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 21:01:32 2024 UTC