1--TEST--
2Phar: tar with huge filenames, buffer overflow
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.require_hash=0
7--FILE--
8<?php
9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
10$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.2.tar';
11$pname = 'phar://' . $fname;
12
13include __DIR__ . '/files/make.dangerous.tar.php.inc';
14
15$tar = new danger_tarmaker($fname, 'none');
16$tar->init();
17$tar->addFile(str_repeat('a', 101), 'hi');
18$tar->addFile(str_repeat('a', 255), 'hi2');
19$tar->close();
20
21$p1 = new PharData($fname);
22foreach ($p1 as $file) {
23    echo $file->getFileName(), "\n";
24}
25echo $p1['a/' . str_repeat('a', 100)]->getContent() . "\n";
26echo $p1[str_repeat('a', 155) . '/' . str_repeat('a', 100)]->getContent() . "\n";
27
28?>
29--CLEAN--
30<?php
31unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
32unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
33?>
34--EXPECT--
35a
36aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
37hi
38hi2
39