Skip to content

Commit 11649a6

Browse files
committed
Reduce size limit in parser fuzzer
Avoid stack overflows during compilation of deeply nested expressions.
1 parent ab6b412 commit 11649a6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sapi/fuzzer/fuzzer-parser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
2929
char *s;
30-
if (Size > 64 * 1024) {
30+
if (Size > 32 * 1024) {
3131
/* Large inputs have a large impact on fuzzer performance,
3232
* but are unlikely to be necessary to reach new codepaths. */
3333
return 0;

sapi/fuzzer/generate_parser_corpus.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
$corpusDir = __DIR__ . '/corpus/parser';
1010
@mkdir($corpusDir);
1111

12+
$maxLen = 32 * 1024;
1213
foreach ($it as $file) {
1314
if (!preg_match('/\.phpt$/', $file)) continue;
1415
$code = file_get_contents($file);
1516
if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $code, $matches)) continue;
1617
$code = $matches[1];
18+
if (strlen($code) > $maxLen) continue;
1719

1820
$outFile = str_replace($testsDir, '', $file);
1921
$outFile = str_replace('/', '_', $outFile);

0 commit comments

Comments
 (0)