]> granicus.if.org Git - php/commitdiff
new tests for corrupted zips
authorGreg Beaver <cellog@php.net>
Sat, 19 Apr 2008 05:58:40 +0000 (05:58 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 19 Apr 2008 05:58:40 +0000 (05:58 +0000)
ext/phar/tests/zip/corrupt_001.phpt [new file with mode: 0644]
ext/phar/tests/zip/corrupt_007.phpt [new file with mode: 0644]
ext/phar/tests/zip/files/corrupt2.php.inc
ext/phar/tests/zip/files/encrypted.zip
ext/phar/tests/zip/files/stdin.zip
ext/phar/tests/zip/files/truncfilename.zip [new file with mode: 0644]

diff --git a/ext/phar/tests/zip/corrupt_001.phpt b/ext/phar/tests/zip/corrupt_001.phpt
new file mode 100644 (file)
index 0000000..0b019c6
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Phar: corrupted zip (count mismatch)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+       new PharData(dirname(__FILE__) . '/files/count1.zip');
+} catch (Exception $e) {
+       echo $e->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 (file)
index 0000000..80c9139
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (truncated filename record)
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
+--FILE--
+<?php
+try {
+       new PharData(dirname(__FILE__) . '/files/truncfilename.zip');
+} catch (Exception $e) {
+       echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: corrupted central directory entry, no magic signature in zip-based phar "%struncfilename.zip"
+===DONE===
index 646eb1bb93efa649c6d6b1e39ea943076bce6d75..27b2f15412d0a921a2ae817c9cf2467cb11dffc3 100644 (file)
@@ -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');
 ?>
index bb3727df2505836d08dcaef08e7cd56a0bd16da1..99a38c821a3d399ed8aafa3e5c0801799951c70a 100644 (file)
Binary files a/ext/phar/tests/zip/files/encrypted.zip and b/ext/phar/tests/zip/files/encrypted.zip differ
index fdbe930983cb8a9fca4f5b6a41dd9917aef5f3e3..836b74d8cd9fc3da5005fa43732e0b8b65f3df60 100644 (file)
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 (file)
index 0000000..1682e1f
Binary files /dev/null and b/ext/phar/tests/zip/files/truncfilename.zip differ