From: Marcus Boerger Date: Wed, 11 Jan 2006 23:54:30 +0000 (+0000) Subject: - Add new test X-Git-Tag: RELEASE_1_0_4~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae81cb9a1cdc75204fa84dc72e3c671c27e7e651;p=php - Add new test --- diff --git a/ext/phar/tests/016b.phpt b/ext/phar/tests/016b.phpt new file mode 100755 index 0000000000..db9df5853d --- /dev/null +++ b/ext/phar/tests/016b.phpt @@ -0,0 +1,35 @@ +--TEST-- +Phar::mapPhar invalid file (gzipped file length is too short) +--SKIPIF-- + +--FILE-- +"; +// file length is too short + +$files = array(); +$files['a'] = 'a'; +$manifest = ''; +foreach($files as $name => $cont) { + $len = strlen($cont); + $manifest .= pack('V', strlen($name)) . $name . pack('VVVVC', $len, time(), 3, crc32($cont), 0x01); +} +$alias = 'hio'; +$manifest = pack('VnV', count($files), 0x0800, strlen($alias)) . $alias . $manifest; +$file .= pack('V', strlen($manifest)) . $manifest; +foreach($files as $cont) +{ + $file .= chr(0) . chr(4) . chr(0); // 'a' gzdeflated +} + +file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file); +include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +echo file_get_contents('phar://hio/a'); +?> +--CLEAN-- + +--EXPECTF-- +Warning: file_get_contents(phar://hio/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d \ No newline at end of file