diff options
author | Greg Beaver <cellog@php.net> | 2008-08-21 20:36:21 +0000 |
---|---|---|
committer | Greg Beaver <cellog@php.net> | 2008-08-21 20:36:21 +0000 |
commit | a036fadb910cf517aec7645e97846208218a4df0 (patch) | |
tree | 699ddb381563b6e67b635f644fdafe8380548750 | |
parent | 1f0f4b56e7ec886f27365d32c81c30d7bd93ada7 (diff) | |
download | php-git-a036fadb910cf517aec7645e97846208218a4df0.tar.gz |
MFB increase code coverage
-rw-r--r-- | ext/phar/tests/zip/corrupt_009.phpt | 17 | ||||
-rw-r--r-- | ext/phar/tests/zip/corrupt_010.phpt | 17 | ||||
-rw-r--r-- | ext/phar/tests/zip/files/corrupt3.php.inc | 9 | ||||
-rw-r--r-- | ext/phar/tests/zip/files/corrupt_zipmaker.php.inc | 15 | ||||
-rw-r--r-- | ext/phar/tests/zip/files/disknumber.zip | bin | 0 -> 105 bytes | |||
-rw-r--r-- | ext/phar/tests/zip/files/extralen_toolong.zip | bin | 0 -> 112 bytes |
6 files changed, 58 insertions, 0 deletions
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-- +<?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/extralen_toolong.zip'); +} catch (Exception $e) { + echo $e->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-- +<?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/disknumber.zip'); +} catch (Exception $e) { + echo $e->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 @@ +<?php +include dirname(__FILE__) . '/corrupt_zipmaker.php.inc'; +$a = new corrupt_zipmaker; +$a->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 Binary files differnew file mode 100644 index 0000000000..f20db05b47 --- /dev/null +++ b/ext/phar/tests/zip/files/disknumber.zip diff --git a/ext/phar/tests/zip/files/extralen_toolong.zip b/ext/phar/tests/zip/files/extralen_toolong.zip Binary files differnew file mode 100644 index 0000000000..a03a4033d6 --- /dev/null +++ b/ext/phar/tests/zip/files/extralen_toolong.zip |