Skip to content

Commit 914198f

Browse files
committed
regex: reject large patterns when fuzzing
Otherwise we risk timeouts. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61484
1 parent fc9a11a commit 914198f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

fuzz/fuzz_targets/fuzz_regex_match.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ re.is_match({haystack:?});
5454
fuzz_target!(|case: FuzzCase| -> Corpus {
5555
let _ = env_logger::try_init();
5656

57+
if case.pattern.len() > (16 * (1 << 10)) {
58+
return Corpus::Reject;
59+
}
5760
if case.haystack.len() > (16 * (1 << 10)) {
5861
return Corpus::Reject;
5962
}
@@ -65,8 +68,11 @@ fuzz_target!(|case: FuzzCase| -> Corpus {
6568
.ignore_whitespace(case.ignore_whitespace)
6669
.unicode(case.unicode)
6770
.octal(case.octal)
68-
.size_limit(1<<18)
69-
.build() else { return Corpus::Reject };
71+
.size_limit(1 << 18)
72+
.build()
73+
else {
74+
return Corpus::Reject;
75+
};
7076
re.is_match(case.haystack);
7177
Corpus::Keep
7278
});

0 commit comments

Comments
 (0)