From: Greg Beaver Date: Sat, 19 Apr 2008 05:51:10 +0000 (+0000) Subject: new test for encrypted zips X-Git-Tag: RELEASE_2_0_0b1~324 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=78c55d2f6d259409eed1d2391c166ba36e2607d0;p=php new test for encrypted zips --- 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 0000000000..00aed14f04 Binary files /dev/null and b/ext/phar/tests/zip/files/encrypted.zip differ