]> granicus.if.org Git - php/commitdiff
new corrupt zip test
authorGreg Beaver <cellog@php.net>
Sat, 19 Apr 2008 05:35:03 +0000 (05:35 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 19 Apr 2008 05:35:03 +0000 (05:35 +0000)
ext/phar/tests/zip/corrupt_002.phpt [new file with mode: 0644]
ext/phar/tests/zip/files/corrupt_count1.php.inc
ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
ext/phar/tests/zip/files/count1.zip
ext/phar/tests/zip/files/count2.zip
ext/phar/tests/zip/files/nozipend.zip [new file with mode: 0644]

diff --git a/ext/phar/tests/zip/corrupt_002.phpt b/ext/phar/tests/zip/corrupt_002.phpt
new file mode 100644 (file)
index 0000000..86a2712
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Phar: corrupted zip (no end of zip 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/nozipend.zip');
+} catch (Exception $e) {
+       echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: end of central directory not found in zip-based phar "%snozipend.zip"
+===DONE===
index 59017d6030fba6510d190d1ccb871a4b1c9e2c82..2a5e01a8fda592cb6bd1c52b4d10e2b9b4d7a104 100644 (file)
@@ -5,4 +5,5 @@ $a->addFile('hi', null, 'hii');
 $a->addFile('hi2', null, 'hii2');
 $a->writeZip(dirname(__FILE__) . '/count1.zip', 'count1');
 $a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2');
+$a->writeZip(dirname(__FILE__) . '/nozipend.zip', 'none');
 ?>
index 315cca0c1933fdbd7d286527d8fe2c66de604a96..98d99ce24d09579dab84279e88b864cda1aa6e66 100644 (file)
@@ -279,6 +279,7 @@ class corrupt_zipmaker
                                        strlen($this->start), $this->offset + 1,
                                        strlen($this->comment) + 1) . $this->comment;
                                break;
+                       case 'none' :
                }
                file_put_contents($zipfile, $write);
        }
index 3b9577229a4bbdf6fd736d9112b211efc2a53eee..adfb4a9f1e373444a5991bc051ade88b55e43ad8 100644 (file)
Binary files a/ext/phar/tests/zip/files/count1.zip and b/ext/phar/tests/zip/files/count1.zip differ
index 8dfd82e540e672319a6cec2d75b84647fd9fda2f..6976cb1a1f5b08219eff72ccb1572cf625fb8b25 100644 (file)
Binary files a/ext/phar/tests/zip/files/count2.zip and b/ext/phar/tests/zip/files/count2.zip differ
diff --git a/ext/phar/tests/zip/files/nozipend.zip b/ext/phar/tests/zip/files/nozipend.zip
new file mode 100644 (file)
index 0000000..b64f597
Binary files /dev/null and b/ext/phar/tests/zip/files/nozipend.zip differ