mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Reduce size limit in parser fuzzer
Avoid stack overflows during compilation of deeply nested expressions.
This commit is contained in:
parent
ab6b412a0b
commit
11649a6d77
2 changed files with 3 additions and 1 deletions
|
@ -27,7 +27,7 @@
|
|||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
char *s;
|
||||
if (Size > 64 * 1024) {
|
||||
if (Size > 32 * 1024) {
|
||||
/* Large inputs have a large impact on fuzzer performance,
|
||||
* but are unlikely to be necessary to reach new codepaths. */
|
||||
return 0;
|
||||
|
|
|
@ -9,11 +9,13 @@ $it = new RecursiveIteratorIterator(
|
|||
$corpusDir = __DIR__ . '/corpus/parser';
|
||||
@mkdir($corpusDir);
|
||||
|
||||
$maxLen = 32 * 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue