xref: /PHP-8.2/ext/phar/tests/010.phpt (revision 74859783)
1--TEST--
2Phar::mapPhar buffer overrun
3--EXTENSIONS--
4phar
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(__DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
19try {
20include __DIR__ . '/' . 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(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
28--EXPECTF--
29internal corruption of phar "%s" (too many manifest entries for size of manifest)
30