From: Greg Beaver Date: Sat, 19 Apr 2008 05:58:40 +0000 (+0000) Subject: new tests for corrupted zips X-Git-Tag: RELEASE_2_0_0b1~322 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa61e6066cc54c8ae046c976189d8d88a1636501;p=php new tests for corrupted zips --- diff --git a/ext/phar/tests/zip/corrupt_001.phpt b/ext/phar/tests/zip/corrupt_001.phpt new file mode 100644 index 0000000000..0b019c6d83 --- /dev/null +++ b/ext/phar/tests/zip/corrupt_001.phpt @@ -0,0 +1,23 @@ +--TEST-- +Phar: corrupted zip (count mismatch) +--SKIPIF-- + + +--FILE-- +getMessage() . "\n"; +} +try { + new PharData(dirname(__FILE__) . '/files/count2.zip'); +} catch (Exception $e) { + echo $e->getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar "%scount1.zip" +phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar "%scount2.zip" +===DONE=== diff --git a/ext/phar/tests/zip/corrupt_007.phpt b/ext/phar/tests/zip/corrupt_007.phpt new file mode 100644 index 0000000000..80c9139025 --- /dev/null +++ b/ext/phar/tests/zip/corrupt_007.phpt @@ -0,0 +1,17 @@ +--TEST-- +Phar: corrupted zip (truncated filename record) +--SKIPIF-- + + +--FILE-- +getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +phar error: corrupted central directory entry, no magic signature in zip-based phar "%struncfilename.zip" +===DONE=== diff --git a/ext/phar/tests/zip/files/corrupt2.php.inc b/ext/phar/tests/zip/files/corrupt2.php.inc index 646eb1bb93..27b2f15412 100644 --- a/ext/phar/tests/zip/files/corrupt2.php.inc +++ b/ext/phar/tests/zip/files/corrupt2.php.inc @@ -8,4 +8,8 @@ $a = new corrupt_zipmaker; $a->addFile('hi', null, 'hii'); $a->addFile('', null, 'stdin'); $a->writeZip(dirname(__FILE__) . '/stdin.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hii', null, 'hii', null, null, 'filename_len', 'filename_len'); +$a->addFile('hi', null, 'hii'); +$a->writeZip(dirname(__FILE__) . '/truncfilename.zip'); ?> diff --git a/ext/phar/tests/zip/files/encrypted.zip b/ext/phar/tests/zip/files/encrypted.zip index bb3727df25..99a38c821a 100644 Binary files a/ext/phar/tests/zip/files/encrypted.zip and b/ext/phar/tests/zip/files/encrypted.zip differ diff --git a/ext/phar/tests/zip/files/stdin.zip b/ext/phar/tests/zip/files/stdin.zip index fdbe930983..836b74d8cd 100644 Binary files a/ext/phar/tests/zip/files/stdin.zip and b/ext/phar/tests/zip/files/stdin.zip differ diff --git a/ext/phar/tests/zip/files/truncfilename.zip b/ext/phar/tests/zip/files/truncfilename.zip new file mode 100644 index 0000000000..1682e1f0aa Binary files /dev/null and b/ext/phar/tests/zip/files/truncfilename.zip differ