From: Greg Beaver Date: Thu, 21 Aug 2008 20:36:21 +0000 (+0000) Subject: MFB increase code coverage X-Git-Tag: BEFORE_HEAD_NS_CHANGE~620 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a036fadb910cf517aec7645e97846208218a4df0;p=php MFB increase code coverage --- diff --git a/ext/phar/tests/zip/corrupt_009.phpt b/ext/phar/tests/zip/corrupt_009.phpt new file mode 100644 index 0000000000..91f142da7b --- /dev/null +++ b/ext/phar/tests/zip/corrupt_009.phpt @@ -0,0 +1,17 @@ +--TEST-- +Phar: corrupted zip (extra field way too long) +--SKIPIF-- + + +--FILE-- +getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +phar error: Unable to process extra field header for file in central directory in zip-based phar "%sextralen_toolong.zip" +===DONE=== diff --git a/ext/phar/tests/zip/corrupt_010.phpt b/ext/phar/tests/zip/corrupt_010.phpt new file mode 100644 index 0000000000..ead723c825 --- /dev/null +++ b/ext/phar/tests/zip/corrupt_010.phpt @@ -0,0 +1,17 @@ +--TEST-- +Phar: unable to process zip (zip spanning multiple archives) +--SKIPIF-- + + +--FILE-- +getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +phar error: split archives spanning multiple zips cannot be processed in zip-based phar "%sdisknumber.zip" +===DONE=== diff --git a/ext/phar/tests/zip/files/corrupt3.php.inc b/ext/phar/tests/zip/files/corrupt3.php.inc new file mode 100644 index 0000000000..05ba70b61c --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt3.php.inc @@ -0,0 +1,9 @@ +addFile('hi', null, 'hii', null, null, null, 'extralen1'); +$a->writeZip(dirname(__FILE__) . '/extralen_toolong.zip'); +$a = new corrupt_zipmaker; +$a->addFile('hi', null, 'hii'); +$a->writeZip(dirname(__FILE__) . '/disknumber.zip', 'disknumber'); +?> diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc index 2c1719920d..9fbfe341c3 100644 --- a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc +++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc @@ -237,6 +237,15 @@ class corrupt_zipmaker $filename . $comment; $offset = strlen($central); break; + case 'extralen1' : + $extra = 'nu' . 0xffff; // way huge size + $central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) . + $mtime . + pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00, + 0x0000, $this->offset). + $filename . $extra . $comment; + $offset = strlen($central); + break; } return $central; } @@ -279,6 +288,12 @@ class corrupt_zipmaker $this->offset, strlen($this->start), strlen($this->comment)) . $this->comment; break; + case 'disknumber' : + $write .= "PK\x05\x06\x01\x00\x01\x00" . + pack("vvVVv", $this->count, $this->count, + $this->offset, strlen($this->start), + strlen($this->comment)) . $this->comment; + break; case 'count1' : $write .= "PK\x05\x06\x00\x00\x00\x00" . pack("vvVVv", $this->count + 1, $this->count, diff --git a/ext/phar/tests/zip/files/disknumber.zip b/ext/phar/tests/zip/files/disknumber.zip new file mode 100644 index 0000000000..f20db05b47 Binary files /dev/null and b/ext/phar/tests/zip/files/disknumber.zip differ diff --git a/ext/phar/tests/zip/files/extralen_toolong.zip b/ext/phar/tests/zip/files/extralen_toolong.zip new file mode 100644 index 0000000000..a03a4033d6 Binary files /dev/null and b/ext/phar/tests/zip/files/extralen_toolong.zip differ