From: Hannes Magnusson Date: Mon, 29 Aug 2011 16:05:45 +0000 (+0000) Subject: Fixed bug#53872 (internal corruption of phar) X-Git-Tag: php-5.3.9RC1~330 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e723c7631c0535a47397cd38ddb826db2a499ed0;p=php Fixed bug#53872 (internal corruption of phar) --- diff --git a/NEWS b/NEWS index d34da25b4b..fd58463c30 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ PHP NEWS - 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 diff --git a/ext/phar/tests/bug53872.phpt b/ext/phar/tests/bug53872.phpt new file mode 100644 index 0000000000..490ae6fd4c --- /dev/null +++ b/ext/phar/tests/bug53872.phpt @@ -0,0 +1,23 @@ +--TEST-- +bug#53872 (internal corruption of phar) +--INI-- +phar.readonly=0 +--FILE-- +buildFromDirectory(__DIR__ . "/bug53872/"); +$p->setStub(''); +$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-- + +--EXPECT-- +content of first.txt +content of third.txt + diff --git a/ext/phar/tests/bug53872/first.txt b/ext/phar/tests/bug53872/first.txt new file mode 100644 index 0000000000..90a4d1f092 --- /dev/null +++ b/ext/phar/tests/bug53872/first.txt @@ -0,0 +1 @@ +content of first.txt diff --git a/ext/phar/tests/bug53872/second.txt b/ext/phar/tests/bug53872/second.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ext/phar/tests/bug53872/third.txt b/ext/phar/tests/bug53872/third.txt new file mode 100644 index 0000000000..4f283cd78f --- /dev/null +++ b/ext/phar/tests/bug53872/third.txt @@ -0,0 +1 @@ +content of third.txt diff --git a/ext/phar/util.c b/ext/phar/util.c index 4706571b06..9b0d8d91c2 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1000,10 +1000,12 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS 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);