mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00

Still seeing stack overflows for $$$$$x style input, let's reduce the input size limit further...
24 lines
716 B
PHP
24 lines
716 B
PHP
<?php
|
|
|
|
$testsDir = __DIR__ . '/../../Zend/tests/';
|
|
$it = new RecursiveIteratorIterator(
|
|
new RecursiveDirectoryIterator($testsDir),
|
|
RecursiveIteratorIterator::LEAVES_ONLY
|
|
);
|
|
|
|
$corpusDir = __DIR__ . '/corpus/parser';
|
|
@mkdir($corpusDir);
|
|
|
|
$maxLen = 6 * 1024;
|
|
foreach ($it as $file) {
|
|
if (!preg_match('/\.phpt$/', $file)) continue;
|
|
$code = file_get_contents($file);
|
|
if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $code, $matches)) continue;
|
|
$code = $matches[1];
|
|
if (strlen($code) > $maxLen) continue;
|
|
|
|
$outFile = str_replace($testsDir, '', $file);
|
|
$outFile = str_replace('/', '_', $outFile);
|
|
$outFile = $corpusDir . '/' . $outFile;
|
|
file_put_contents($outFile, $code);
|
|
}
|