From: Greg Beaver Date: Sat, 11 Oct 2008 21:02:53 +0000 (+0000) Subject: MFB: work around crap stream filter implementation, update tests for compressed alias... X-Git-Tag: BEFORE_HEAD_NS_CHANGE~250 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a04372a2db137262778dfad7bec3d1aaef5f9ab;p=php MFB: work around crap stream filter implementation, update tests for compressed aliases in zip-based phar so they actually test the compression --- diff --git a/ext/phar/tests/zip/bzip2.phpt b/ext/phar/tests/zip/bzip2.phpt index 208f79a47b..a703ce6033 100644 --- a/ext/phar/tests/zip/bzip2.phpt +++ b/ext/phar/tests/zip/bzip2.phpt @@ -79,5 +79,5 @@ $a = new corrupt_zipmaker; $a->addFile('hi', null, 'hii', null, null, 'compress', 'compress', 11); $a->writeZip(dirname(__FILE__) . '/compress_unsupunknown.zip'); ?> -string(7) "hithere" +string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip" ===DONE=== diff --git a/ext/phar/tests/zip/files/bz2_alias.phar.zip b/ext/phar/tests/zip/files/bz2_alias.phar.zip index 2bab490a88..8d3082adb8 100644 Binary files a/ext/phar/tests/zip/files/bz2_alias.phar.zip and b/ext/phar/tests/zip/files/bz2_alias.phar.zip differ diff --git a/ext/phar/tests/zip/files/zlib_alias.phar.zip b/ext/phar/tests/zip/files/zlib_alias.phar.zip new file mode 100644 index 0000000000..d6f98e8916 Binary files /dev/null and b/ext/phar/tests/zip/files/zlib_alias.phar.zip differ diff --git a/ext/phar/tests/zip/zlib.phpt b/ext/phar/tests/zip/zlib.phpt new file mode 100644 index 0000000000..c7494e2c61 --- /dev/null +++ b/ext/phar/tests/zip/zlib.phpt @@ -0,0 +1,19 @@ +--TEST-- +Phar: process zlib-compressed zip alias +--SKIPIF-- + + + +--FILE-- +getAlias()); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; +} +?> +===DONE=== +--EXPECT-- +string(175) "hitheresuperlongzipistoostupidtodowhatIsaysoIhavetousethisridiculouslylongaliasbecauseitisstupiddidImentionthatalreadythemadnessdoesnotstopIhateinfozipIhateinfozipIhateinfozip" +===DONE=== diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 221a806f55..c64db266b6 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -489,6 +489,13 @@ foundit: fp->writepos = fp->readpos = 0; #endif php_stream_seek(fp, entry.offset, SEEK_SET); + /* these next lines should be for php < 5.2.6 after 5.3 filters are fixed */ + fp->writepos = 0; + fp->readpos = 0; + php_stream_seek(fp, entry.offset, SEEK_SET); + fp->writepos = 0; + fp->readpos = 0; + /* the above lines should be for php < 5.2.6 after 5.3 filters are fixed */ mydata->alias_len = entry.uncompressed_filesize; @@ -504,6 +511,9 @@ foundit: if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { pefree(entry.filename, entry.is_persistent); +#if PHP_VERSION_ID < 50207 + PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); +#endif PHAR_ZIP_FAIL("unable to read in alias, truncated"); } @@ -522,6 +532,9 @@ foundit: if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) { pefree(entry.filename, entry.is_persistent); +#if PHP_VERSION_ID < 50207 + PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)"); +#endif PHAR_ZIP_FAIL("unable to read in alias, truncated"); }