1--TEST--
2GHSA-jqcx-ccgc-xwhv (Buffer overflow and overread in phar_dir_read())
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9$phar = new Phar(__DIR__. '/GHSA-jqcx-ccgc-xwhv.phar');
10$phar->startBuffering();
11$phar->addFromString(str_repeat('A', PHP_MAXPATHLEN - 1), 'This is the content of file 1.');
12$phar->addFromString(str_repeat('B', PHP_MAXPATHLEN - 1).'C', 'This is the content of file 2.');
13$phar->stopBuffering();
14
15$handle = opendir('phar://' . __DIR__ . '/GHSA-jqcx-ccgc-xwhv.phar');
16var_dump(strlen(readdir($handle)));
17// Must not be a string of length PHP_MAXPATHLEN+1
18var_dump(readdir($handle));
19closedir($handle);
20?>
21--CLEAN--
22<?php
23unlink(__DIR__. '/GHSA-jqcx-ccgc-xwhv.phar');
24?>
25--EXPECTF--
26int(%d)
27bool(false)
28