From 78c55d2f6d259409eed1d2391c166ba36e2607d0 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sat, 19 Apr 2008 05:51:10 +0000 Subject: [PATCH] new test for encrypted zips --- ext/phar/tests/zip/corrupt_005.phpt | 17 +++++++++++++++++ ext/phar/tests/zip/files/corrupt2.php.inc | 7 +++++++ .../tests/zip/files/corrupt_zipmaker.php.inc | 15 +++++++++++++++ ext/phar/tests/zip/files/encrypted.zip | Bin 0 -> 191 bytes 4 files changed, 39 insertions(+) create mode 100644 ext/phar/tests/zip/corrupt_005.phpt create mode 100644 ext/phar/tests/zip/files/corrupt2.php.inc create mode 100644 ext/phar/tests/zip/files/encrypted.zip diff --git a/ext/phar/tests/zip/corrupt_005.phpt b/ext/phar/tests/zip/corrupt_005.phpt new file mode 100644 index 0000000000..6b5d31d967 --- /dev/null +++ b/ext/phar/tests/zip/corrupt_005.phpt @@ -0,0 +1,17 @@ +--TEST-- +Phar: encrypted zip +--SKIPIF-- + + +--FILE-- +getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +phar error: Cannot process encrypted zip files in zip-based phar "%sencrypted.zip" +===DONE=== diff --git a/ext/phar/tests/zip/files/corrupt2.php.inc b/ext/phar/tests/zip/files/corrupt2.php.inc new file mode 100644 index 0000000000..b396d58290 --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt2.php.inc @@ -0,0 +1,7 @@ +addFile('hi', null, 'hii'); +$a->addFile('hi2', null, 'hii2', null, null, 'encrypt', 'encrypt'); +$a->writeZip(dirname(__FILE__) . '/encrypted.zip'); +?> diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc index 3279176a95..0a8cab6e8f 100644 --- a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc +++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc @@ -94,6 +94,13 @@ class corrupt_zipmaker $filename . $data; break; + case 'encrypt' : + $file = "PK\x03\x04\x14\x00\x01\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvv", $crc32, $complength, $uncomplength, strlen($filename), 0x00) . + $filename . + $data; + break; case 'crc32' : $file = "PK\x03\x04\x14\x00\x00\x00" . pack('v', $compmethod) . $mtime . @@ -159,6 +166,14 @@ class corrupt_zipmaker $filename . $comment; $offset = strlen($central); break; + case 'encrypt' : + $central = "PK\x01\x02\x00\x00\x14\x00\x01\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), 0x00,strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $comment; + $offset = strlen($central); + break; case 'crc32' : $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . $mtime . diff --git a/ext/phar/tests/zip/files/encrypted.zip b/ext/phar/tests/zip/files/encrypted.zip new file mode 100644 index 0000000000000000000000000000000000000000..00aed14f04f0211ccc9d52ccc3c8cf86b24cf4bb GIT binary patch literal 191 zcmWIWW@Zs#0D)|_$rdxbu2?by*&xgW#2J|xnVA7#C5%udhJ_YSSb%I01}V$PGy