<?php
$stub = "<?php __HALT_COMPILER(); ?>\r\n";
function u32($v) { return pack('V', $v); }
function ent($name, $data, $meta = '') {
$h = u32(strlen($name)) . $name
. u32(strlen($data)) . u32(0) . u32(strlen($data))
. u32(crc32($data)) . u32(0)
. u32(strlen($meta)) . $meta;
return [$h, $data];
}
$e1 = ent('a.txt', 'hello', 'i:1;');
$e2 = ent('a.txt', 'world', 'i:2;');
$ents = $e1[0] . $e2[0];
$contents = $e1[1] . $e2[1];
$manifest = u32(2) . "\x11\x00" . u32(0) . u32(0) . u32(0) . $ents;
file_put_contents(__DIR__ . '/dup.phar', $stub . u32(strlen($manifest)) . $manifest . $contents);
$p = new Phar(__DIR__ . '/dup.phar');
echo iterator_count($p), PHP_EOL;
==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#4 zend_string_init Zend/zend_string.h:212
#5 phar_parse_metadata_lazy ext/phar/phar.c:705
#6 phar_parse_pharfile ext/phar/phar.c:1191
#10 zim_Phar___construct ext/phar/phar_object.c:1125
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#4 zend_string_init Zend/zend_string.h:212
#5 phar_parse_pharfile ext/phar/phar.c:1177
#9 zim_Phar___construct ext/phar/phar_object.c:1125
Description
Originally posted by @devnexen in #23418
The following code:
Resulted in this output:
PHP Version
Operating System
/