bjori Mon, 29 Aug 2011 16:05:45 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=315713
Log:
Fixed bug#53872 (internal corruption of phar)
Bug: https://bugs.php.net/53872 (Open) internal corruption of phar
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
A php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/
A php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/first.txt
A php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/second.txt
A php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/third.txt
A php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872.phpt
U php/php-src/branches/PHP_5_3/ext/phar/util.c
A php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/
A php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/first.txt
A php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/second.txt
A php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/third.txt
A php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872.phpt
U php/php-src/branches/PHP_5_4/ext/phar/util.c
A php/php-src/trunk/ext/phar/tests/bug53872/
A php/php-src/trunk/ext/phar/tests/bug53872/first.txt
A php/php-src/trunk/ext/phar/tests/bug53872/second.txt
A php/php-src/trunk/ext/phar/tests/bug53872/third.txt
A php/php-src/trunk/ext/phar/tests/bug53872.phpt
U php/php-src/trunk/ext/phar/util.c
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2011-08-29 15:53:46 UTC (rev 315712)
+++ php/php-src/branches/PHP_5_3/NEWS 2011-08-29 16:05:45 UTC (rev 315713)
@@ -8,6 +8,7 @@
- Phar:
. Fixed bug#52013 (Unable to decompress files in a compressed phar). (Hannes)
+ . Fixed bug#53872 (internal corruption of phar). (Hannes)
- NSAPI SAPI:
. Don't set $_SERVER['HTTPS'] on unsecure connection (bug #55403). (Uwe
Added: php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/first.txt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/first.txt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/first.txt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1 @@
+content of first.txt
Added: php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/second.txt
===================================================================
Added: php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/third.txt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/third.txt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872/third.txt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1 @@
+content of third.txt
Added: php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/phar/tests/bug53872.phpt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1,23 @@
+--TEST--
+bug#53872 (internal corruption of phar)
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p=new Phar('bug53872-phar.phar');
+$p->buildFromDirectory(__DIR__ . "/bug53872/");
+$p->setStub('<?php __HALT_COMPILER();?\>');
+$p->compressFiles(Phar::GZ);
+
+print(file_get_contents('phar://bug53872-phar.phar/first.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/second.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/third.txt'));
+?>
+--CLEAN--
+<?php
+unlink("bug53872-phar.phar");
+?>
+--EXPECT--
+content of first.txt
+content of third.txt
+
Modified: php/php-src/branches/PHP_5_3/ext/phar/util.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/phar/util.c 2011-08-29 15:53:46 UTC (rev 315712)
+++ php/php-src/branches/PHP_5_3/ext/phar/util.c 2011-08-29 16:05:45 UTC (rev 315713)
@@ -1000,10 +1000,12 @@
php_stream_filter_append(&ufp->writefilters, filter);
php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET);
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
- spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- return FAILURE;
+ if (entry->uncompressed_filesize) {
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
+ spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ return FAILURE;
+ }
}
php_stream_filter_flush(filter, 1);
Added: php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/first.txt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/first.txt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/first.txt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1 @@
+content of first.txt
Added: php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/second.txt
===================================================================
Added: php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/third.txt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/third.txt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872/third.txt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1 @@
+content of third.txt
Added: php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872.phpt (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/phar/tests/bug53872.phpt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1,23 @@
+--TEST--
+bug#53872 (internal corruption of phar)
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p=new Phar('bug53872-phar.phar');
+$p->buildFromDirectory(__DIR__ . "/bug53872/");
+$p->setStub('<?php __HALT_COMPILER();?\>');
+$p->compressFiles(Phar::GZ);
+
+print(file_get_contents('phar://bug53872-phar.phar/first.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/second.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/third.txt'));
+?>
+--CLEAN--
+<?php
+unlink("bug53872-phar.phar");
+?>
+--EXPECT--
+content of first.txt
+content of third.txt
+
Modified: php/php-src/branches/PHP_5_4/ext/phar/util.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/phar/util.c 2011-08-29 15:53:46 UTC (rev 315712)
+++ php/php-src/branches/PHP_5_4/ext/phar/util.c 2011-08-29 16:05:45 UTC (rev 315713)
@@ -999,10 +999,12 @@
php_stream_filter_append(&ufp->writefilters, filter);
php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET);
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
- spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- return FAILURE;
+ if (entry->uncompressed_filesize) {
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
+ spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ return FAILURE;
+ }
}
php_stream_filter_flush(filter, 1);
Added: php/php-src/trunk/ext/phar/tests/bug53872/first.txt
===================================================================
--- php/php-src/trunk/ext/phar/tests/bug53872/first.txt (rev 0)
+++ php/php-src/trunk/ext/phar/tests/bug53872/first.txt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1 @@
+content of first.txt
Added: php/php-src/trunk/ext/phar/tests/bug53872/second.txt
===================================================================
Added: php/php-src/trunk/ext/phar/tests/bug53872/third.txt
===================================================================
--- php/php-src/trunk/ext/phar/tests/bug53872/third.txt (rev 0)
+++ php/php-src/trunk/ext/phar/tests/bug53872/third.txt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1 @@
+content of third.txt
Added: php/php-src/trunk/ext/phar/tests/bug53872.phpt
===================================================================
--- php/php-src/trunk/ext/phar/tests/bug53872.phpt (rev 0)
+++ php/php-src/trunk/ext/phar/tests/bug53872.phpt 2011-08-29 16:05:45 UTC (rev 315713)
@@ -0,0 +1,23 @@
+--TEST--
+bug#53872 (internal corruption of phar)
+--INI--
+phar.readonly=0
+--FILE--
+<?php
+$p=new Phar('bug53872-phar.phar');
+$p->buildFromDirectory(__DIR__ . "/bug53872/");
+$p->setStub('<?php __HALT_COMPILER();?\>');
+$p->compressFiles(Phar::GZ);
+
+print(file_get_contents('phar://bug53872-phar.phar/first.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/second.txt'));
+print(file_get_contents('phar://bug53872-phar.phar/third.txt'));
+?>
+--CLEAN--
+<?php
+unlink("bug53872-phar.phar");
+?>
+--EXPECT--
+content of first.txt
+content of third.txt
+
Modified: php/php-src/trunk/ext/phar/util.c
===================================================================
--- php/php-src/trunk/ext/phar/util.c 2011-08-29 15:53:46 UTC (rev 315712)
+++ php/php-src/trunk/ext/phar/util.c 2011-08-29 16:05:45 UTC (rev 315713)
@@ -999,10 +999,12 @@
php_stream_filter_append(&ufp->writefilters, filter);
php_stream_seek(phar_get_entrypfp(entry TSRMLS_CC), phar_get_fp_offset(entry TSRMLS_CC), SEEK_SET);
- if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
- spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
- php_stream_filter_remove(filter, 1 TSRMLS_CC);
- return FAILURE;
+ if (entry->uncompressed_filesize) {
+ if (SUCCESS != phar_stream_copy_to_stream(phar_get_entrypfp(entry TSRMLS_CC), ufp, entry->compressed_filesize, NULL)) {
+ spprintf(error, 4096, "phar error: internal corruption of phar \"%s\" (actual filesize mismatch on file \"%s\")", phar->fname, entry->filename);
+ php_stream_filter_remove(filter, 1 TSRMLS_CC);
+ return FAILURE;
+ }
}
php_stream_filter_flush(filter, 1);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php