From: Greg Beaver Date: Sat, 19 Apr 2008 05:45:10 +0000 (+0000) Subject: new test for central directory offset being wrong X-Git-Tag: RELEASE_2_0_0b1~325 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3a4ecf5ab1c666b5be3821edee3ea2ffded0e60;p=php new test for central directory offset being wrong --- diff --git a/ext/phar/tests/zip/corrupt_004.phpt b/ext/phar/tests/zip/corrupt_004.phpt new file mode 100644 index 0000000000..3760e8f9ae --- /dev/null +++ b/ext/phar/tests/zip/corrupt_004.phpt @@ -0,0 +1,17 @@ +--TEST-- +Phar: corrupted zip (central directory offset incorrect) +--SKIPIF-- + + +--FILE-- +getMessage() . "\n"; +} +?> +===DONE=== +--EXPECTF-- +phar error: corrupted central directory entry, no magic signature in zip-based phar "%scdir_offset.zip" +===DONE=== diff --git a/ext/phar/tests/zip/files/cdir_offset.zip b/ext/phar/tests/zip/files/cdir_offset.zip new file mode 100644 index 0000000000..9172554f2d Binary files /dev/null and b/ext/phar/tests/zip/files/cdir_offset.zip differ diff --git a/ext/phar/tests/zip/files/corrupt_count1.php.inc b/ext/phar/tests/zip/files/corrupt_count1.php.inc index 17a3a62e49..314fdef6db 100644 --- a/ext/phar/tests/zip/files/corrupt_count1.php.inc +++ b/ext/phar/tests/zip/files/corrupt_count1.php.inc @@ -7,4 +7,5 @@ $a->writeZip(dirname(__FILE__) . '/count1.zip', 'count1'); $a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2'); $a->writeZip(dirname(__FILE__) . '/nozipend.zip', 'none'); $a->writeZip(dirname(__FILE__) . '/filecomment.zip', 'comment'); +$a->writeZip(dirname(__FILE__) . '/cdir_offset.zip', 'cdir_offset'); ?> diff --git a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc index 98d99ce24d..3279176a95 100644 --- a/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc +++ b/ext/phar/tests/zip/files/corrupt_zipmaker.php.inc @@ -261,16 +261,16 @@ class corrupt_zipmaker $this->offset, strlen($this->start), strlen($this->comment)) . $this->comment; break; - case 'cdir_len' : + case 'cdir_offset' : $write .= "PK\x05\x06\x00\x00\x00\x00" . pack("vvVVv", $this->count, $this->count, $this->offset, strlen($this->start) - 3, strlen($this->comment)) . $this->comment; break; - case 'cdir_offset' : + case 'cdir_len' : $write .= "PK\x05\x06\x00\x00\x00\x00" . pack("vvVVv", $this->count, $this->count, - $this->offset + 1, strlen($this->start), + $this->offset - 5, strlen($this->start), strlen($this->comment)) . $this->comment; break; case 'comment' : diff --git a/ext/phar/tests/zip/files/count1.zip b/ext/phar/tests/zip/files/count1.zip index 2a156cb3f5..73b556103a 100644 Binary files a/ext/phar/tests/zip/files/count1.zip and b/ext/phar/tests/zip/files/count1.zip differ diff --git a/ext/phar/tests/zip/files/count2.zip b/ext/phar/tests/zip/files/count2.zip index 0da6f9c7ba..6aa2619539 100644 Binary files a/ext/phar/tests/zip/files/count2.zip and b/ext/phar/tests/zip/files/count2.zip differ diff --git a/ext/phar/tests/zip/files/filecomment.zip b/ext/phar/tests/zip/files/filecomment.zip index d1f9bfb1ef..414b121fdc 100644 Binary files a/ext/phar/tests/zip/files/filecomment.zip and b/ext/phar/tests/zip/files/filecomment.zip differ diff --git a/ext/phar/tests/zip/files/nozipend.zip b/ext/phar/tests/zip/files/nozipend.zip index d91268c615..f97607221c 100644 Binary files a/ext/phar/tests/zip/files/nozipend.zip and b/ext/phar/tests/zip/files/nozipend.zip differ