}
/* extract the number of entries */
PHAR_GET_VAL(manifest_count)
+ /* we have 4 32-bit items and each must contain a file name at least 1 byte in length */
+ if (manifest_count > (manifest_len / (4 * 5 + 1))) {
+ /* prevent serious memory issues */
+ MAPPHAR_FAIL("too many manifest entries for size of manifest in phar \"%s\"")
+ }
/* set up our manifest */
ALLOC_HASHTABLE(manifest);
zend_hash_init(manifest, sizeof(phar_manifest_entry),
$file .= pack('V', 500) . 'notenough';
file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
include dirname(__FILE__) . '/008_phar.php';
-exit;
-PHP_Archive::mapPhar(5, 'hio', false);
-__HALT_COMPILER(); ?>
+?>
--EXPECTF--
Fatal error: PHP_Archive::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
\ No newline at end of file
--- /dev/null
+--TEST--
+PHP_Archive::mapPhar improper parameters
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip";?>
+--FILE--
+<?php
+function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
+register_shutdown_function('cleanup');
+$file = "<?php
+PHP_Archive::mapPhar(5, 'hio', false);
+__HALT_COMPILER(); ?>";
+$file .= pack('VV', 500, 500) . str_repeat('A', 500);
+file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
+include dirname(__FILE__) . '/008_phar.php';
+?>
+--EXPECTF--
+Fatal error: PHP_Archive::mapPhar(): too many manifest entries for size of manifest in phar "%s" in %s on line %d
\ No newline at end of file