From 8526b7828656a8a192e8b1c6dd74db2aaa8b63e5 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Mon, 11 Aug 2008 03:53:57 +0000 Subject: [PATCH] increase code coverage --- ext/phar/tests/zip/corrupt_009.phpt | 17 +++++++++++++++++ ext/phar/tests/zip/files/corrupt3.php.inc | 6 ++++++ .../tests/zip/files/corrupt_zipmaker.php.inc | 9 +++++++++ ext/phar/tests/zip/files/extralen_toolong.zip | Bin 0 -> 112 bytes 4 files changed, 32 insertions(+) create mode 100644 ext/phar/tests/zip/corrupt_009.phpt create mode 100644 ext/phar/tests/zip/files/corrupt3.php.inc create mode 100644 ext/phar/tests/zip/files/extralen_toolong.zip diff --git a/ext/phar/tests/zip/corrupt_009.phpt b/ext/phar/tests/zip/corrupt_009.phpt new file mode 100644 index 00000000000..91f142da7b2 --- /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/files/corrupt3.php.inc b/ext/phar/tests/zip/files/corrupt3.php.inc new file mode 100644 index 00000000000..aa0cc96d89f --- /dev/null +++ b/ext/phar/tests/zip/files/corrupt3.php.inc @@ -0,0 +1,6 @@ +addFile('hi', null, 'hii', null, null, null, 'extralen1'); +$a->writeZip(dirname(__FILE__) . '/extralen_toolong.zip'); +?> diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc index 2c1719920de..959530f2cfc 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; } 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 0000000000000000000000000000000000000000..a04fa6b0040e6cd2cc07b872c0f4f08258adc1d0 GIT binary patch literal 112 zcmWIWW@Zs#0D;$Axh!XRU9n^avO$;$h%+)XGBX3b8G&qEir9h5kU>UfUa6U>sj+E* RH!B-Rf)NPKfwVGM6#($f4($K{ literal 0 HcmV?d00001