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 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
10$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.tar';
11$pname = 'phar://' . $fname;
12
13include dirname(__FILE__) . '/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===DONE===
30--CLEAN--
31<?php
32unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.tar');
33unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.2.tar');
34?>
35--EXPECT--
36a
37aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
38hi
39hi2
40===DONE===
41