Skip to content

Commit

Permalink
regex: reject large patterns when fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Oct 9, 2023
1 parent fc9a11a commit 914198f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fuzz/fuzz_targets/fuzz_regex_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ re.is_match({haystack:?});
fuzz_target!(|case: FuzzCase| -> Corpus {
let _ = env_logger::try_init();

if case.pattern.len() > (16 * (1 << 10)) {
return Corpus::Reject;
}
if case.haystack.len() > (16 * (1 << 10)) {
return Corpus::Reject;
}
Expand All @@ -65,8 +68,11 @@ fuzz_target!(|case: FuzzCase| -> Corpus {
.ignore_whitespace(case.ignore_whitespace)
.unicode(case.unicode)
.octal(case.octal)
.size_limit(1<<18)
.build() else { return Corpus::Reject };
.size_limit(1 << 18)
.build()
else {
return Corpus::Reject;
};
re.is_match(case.haystack);
Corpus::Keep
});
Binary file not shown.

0 comments on commit 914198f

Please sign in to comment.