Skip to content

Commit a3978b2

Browse files
committed
fuzz: set a size limit
Otherwise it's possible for the fuzzer to build a regex that is big enough to timeout on a big haystack.
1 parent 98be16a commit a3978b2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fuzz/fuzz_targets/fuzz_regex_match.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ fuzz_target!(|data: &[u8]| {
1414
let char_index = data.char_indices().nth(split_off_point);
1515
if let Some((char_index, _)) = char_index {
1616
let (pattern, input) = data.split_at(char_index);
17-
if let Ok(re) = regex::Regex::new(pattern) {
17+
let result =
18+
regex::RegexBuilder::new(pattern).size_limit(1 << 20).build();
19+
if let Ok(re) = result {
1820
re.is_match(input);
1921
}
2022
}

0 commit comments

Comments
 (0)