svn: /pear/packages/Archive_Tar/trunk/Archive/ Tar.php

From: Date: Thu, 05 Apr 2012 08:44:41 +0000
Subject: svn: /pear/packages/Archive_Tar/trunk/Archive/ Tar.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-64616@lists.php.net to get a copy of this message
mrook Thu, 05 Apr 2012 08:44:41 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=324840 Log: Fixes #13361 and #19330 - prevent invalid blocks (orig. patch by Marco Pracucci) Bugs: http://pear.php.net/bugs/13361 (unknown) http://pear.php.net/bugs/19330 (unknown) Changed paths: U pear/packages/Archive_Tar/trunk/Archive/Tar.php Modified: pear/packages/Archive_Tar/trunk/Archive/Tar.php =================================================================== --- pear/packages/Archive_Tar/trunk/Archive/Tar.php 2012-04-05 08:35:11 UTC (rev 324839) +++ pear/packages/Archive_Tar/trunk/Archive/Tar.php 2012-04-05 08:44:41 UTC (rev 324840) @@ -1773,12 +1773,20 @@ } if ($this->_compress_type == 'gz') { + $end_blocks = 0; + while (!@gzeof($v_temp_tar)) { $v_buffer = @gzread($v_temp_tar, 512); if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { + $end_blocks++; // do not copy end blocks, we will re-make them // after appending continue; + } elseif ($end_blocks > 0) { + for ($i = 0; $i < $end_blocks; $i++) { + $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); + } + $end_blocks = 0; } $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data); @@ -1787,9 +1795,19 @@ @gzclose($v_temp_tar); } elseif ($this->_compress_type == 'bz2') { + $end_blocks = 0; + while (strlen($v_buffer = @bzread($v_temp_tar, 512)) > 0) { - if ($v_buffer == ARCHIVE_TAR_END_BLOCK) { + if ($v_buffer == ARCHIVE_TAR_END_BLOCK || strlen($v_buffer) == 0) { + $end_blocks++; + // do not copy end blocks, we will re-make them + // after appending continue; + } elseif ($end_blocks > 0) { + for ($i = 0; $i < $end_blocks; $i++) { + $this->_writeBlock(ARCHIVE_TAR_END_BLOCK); + } + $end_blocks = 0; } $v_binary_data = pack("a512", $v_buffer); $this->_writeBlock($v_binary_data);

« previous php.pear.cvs (#64616) next »