xref: /PHP-7.3/ext/phar/tests/010.phpt (revision 9c5af4e4)
1--TEST--
2Phar::mapPhar buffer overrun
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip");?>
5--INI--
6phar.require_hash=0
7--FILE--
8<?php
9$file = "<?php
10Phar::mapPhar('hio');
11__HALT_COMPILER(); ?>";
12
13// this fails because the manifest length does not include the other 10 byte manifest data
14
15$manifest = pack('V', 1) . 'a' . pack('VVVVVV', 0, time(), 0, crc32(''), 0x00000000, 0);
16$file .= pack('VVnVV', strlen($manifest), 1, 0x1000, 0x00000000, 3) . 'hio' . pack('V', 0) . $manifest;
17
18file_put_contents(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
19try {
20include dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
21echo file_get_contents('phar://hio/a');
22} catch (Exception $e) {
23echo $e->getMessage();
24}
25?>
26--CLEAN--
27<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
28--EXPECTF--
29internal corruption of phar "%s" (too many manifest entries for size of manifest)
30