FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=17578&edit=1

ID: 17578
Comment by: kevinoid
Reported By: kevin at kevinlocke dot name
Summary: Fail to read some POSIX tar files
Status: Open
Type: Bug
Package: Archive_Tar
Operating System: tested on Linux and MaxOSX
Package Version: 1.3.7
PHP Version: 5.3.1
New Comment:

I was just bit by this bug as well. Note that the POSIX ustar format
spec also refers to these 0 blocks as an "end of archive indicator"
implying data after should be ignored. Note also that there are
programs which only generate a single 0-block to indicate the end of
archive and this case is supported by GNU tar (with a warning) and
Python tarfile (no warning) and probably others (those are the only ones
I checked).


Previous Comments:
------------------------------------------------------------------------

[2010-07-11 20:01:17] miketee99

<div id="changeset">
<span class="removed">-Operating System: tested on Linux et
MaxOSX</span>
<span class="added">+Operating System: tested on Linux and MaxOSX</span>
</div>All the modified and added code lines are delimited by comments
like:

// BEGIN !!== Modified/Added by Michel TERESE ==!!
...
// END !!== Modified/Added by Michel TERESE ==!!

The submitted patch can be applied by: patch -p1 Tar.php.patch

------------------------------------------------------------------------

[2010-07-11 19:54:39] miketee99

Added #patch bug:17578;patch:end-of-entry_check;revision:1278878078;.

------------------------------------------------------------------------

[2010-07-11 19:27:12] miketee99

Description:
------------
Some POSIX tar files generated by non GNU tar programs (IBM AIX) cannot
be read by Archive_Tar.

The cause is the following:

The end-of-archive entry not checked.

Detailed explanation:
As described in the tar format
(http://www.gnu.org/software/automake/manual/tar/Standard.html), a tar
archive must end with "an end-of-archive entry, which consists of two
512 blocks of zero bytes".
In the current stable version 1.3.7, the Archive_Tar package don't check
the end-of-archive entry assuming that the tar archive ends at the end
of the tar file.
Generally, there is no more blocks in the tar file beyond the
end-of-archive entry (which would be useless). But, it happens,
sometimes, for an unknown reason, that tar files generated on AIX 5.3.3,
have some garbage blocks appended, after the end-of-archive entry.
In that case, the Archive_Tar package attempt to read inconsistent data
beyond the end of the archive which leads the read methods to fail.

I fixed this, and I do some minor improvements in the block checksum
calculation which can be significant with tar archives containing a huge
quantity of files.


Test script:
---------------
<?php
require_once( 'Archive/Tar.php' );

PEAR::setErrorHandling(PEAR_ERROR_PRINT);

$tar= new Archive_Tar( 'some_tar_file.tar' );
if ( ($v_list= $tar->listContent() ) != 0 ) {
for ( $i= 0; $i < sizeof( $v_list ); $i++ ) {
echo $v_list[$i]['filename']."\n";
}
}
?>


Expected result:
----------------
...
The list of the files contained in the tar file
...


Actual result:
--------------
Invalid checksum for file "t;font-family:"Bookman Old
Style";color:navy'><![if !supportEmptyParas]> <![endif]><o:p></o:p>" :
43686 calculated, 1 expected


(of course, the name of the file reported depends on the content of the
tar file)

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedSep 3, '10 at 4:04p
activeSep 3, '10 at 4:04p
posts1
users1
websitepear.php.net

1 user in discussion

Kevinoid: 1 post

People

Translate

site design / logo © 2022 Grokbase