Skip to content

Commit

Permalink
- Fixed #ZETACOMP-8: Double extraction causes empty file. (Patch by P…
Browse files Browse the repository at this point in the history
…atrick

  Allaert)


git-svn-id: http://svn.ez.no/svn/ezcomponents/trunk@11475 bc0e7bdc-f0fc-0310-8ff6-f601c06e1256
  • Loading branch information
oms committed Sep 8, 2010
1 parent 1235ade commit cc13644
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Archive/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.4.2 - [RELEASEDATE]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fixed #ZETACOMP-8: Double extraction causes empty file. (Patch by Patrick
Allaert)


1.4.1 - Monday 22 March 2010
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
4 changes: 2 additions & 2 deletions Archive/src/tar/v7.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ protected function readCurrentFromArchive()
$newBlock = $this->headerPositions[ $this->fileNumber - 1 ] + $this->file->getBlocksFromBytes( $this->headers[ $this->fileNumber - 1 ]->fileSize );

// Search for that block.
if ( $newBlock != $this->file->key() )
if ( $newBlock !== $this->file->key() )
{
$this->file->seek( $newBlock );
}
Expand Down Expand Up @@ -234,7 +234,7 @@ protected function writeCurrentDataToFile( $targetPath )

$requestedBlock = $this->headerPositions[$this->fileNumber];
$currentBlock = $this->file->key();
if ( $currentBlock != $requestedBlock )
if ( $currentBlock !== $requestedBlock )
{
$this->file->seek( $requestedBlock );
}
Expand Down
Binary file added Archive/tests/data/tar_v7_truncated_block.tar
Binary file not shown.
25 changes: 25 additions & 0 deletions Archive/tests/tar/v7_tar_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,31 @@ public function testAppendArchiveAtOnce()
unset( $bf );
}

/**
* Test for issue ZETACOMP-8: Double extraction causes empty file
*
* The failure happens only with some tarballs. The easiest way to create
* such failing one is to remove some of the nul characters which are
* appended to the file's content to continue the block.
*/
public function testDoubleExtraction()
{
$archive = ezcArchive::open( dirname( dirname( __FILE__ ) ) . "/data/tar_v7_truncated_block.tar" );
$dir = $this->getTempDir();

foreach ( $archive as $entry )
{
if ( $entry->getPath() === "file1" )
{
$archive->extractCurrent( $dir );
// "break;" intentionally omitted.
}
}

$archive->extract( $dir );
$this->assertEquals( 13, filesize( "$dir/file1" ) );
}

public static function suite()
{
return new PHPUnit_Framework_TestSuite( __CLASS__ );
Expand Down

0 comments on commit cc13644

Please sign in to comment.