mirror of
https://github.com/php/php-src.git
synced 2024-10-06 17:26:11 +00:00
35 lines
1.2 KiB
PHP
Executable File
35 lines
1.2 KiB
PHP
Executable File
--TEST--
|
|
Phar::mapPhar invalid file (gzipped file length is too short)
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("phar")) print "skip";
|
|
if (!extension_loaded("zlib")) print "skip zlib not present"; ?>
|
|
--FILE--
|
|
<?php
|
|
$file = "<?php
|
|
Phar::mapPhar('hio');
|
|
__HALT_COMPILER(); ?>";
|
|
// 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(), 1, 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--
|
|
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
|
|
--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
|