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