Skip to content

Commit 97a7b4e

Browse files
committed
drastically simplify fuzzer input
1 parent 5197f21 commit 97a7b4e

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

fuzz/fuzz_targets/fuzz_regex_match.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
#![no_main]
22
use libfuzzer_sys::fuzz_target;
33

4-
fuzz_target!(|data: &[u8]| {
5-
if data.len() < 2 {
6-
return;
7-
}
8-
let split_point = data[0] as usize;
9-
if let Ok(data) = std::str::from_utf8(&data[1..]) {
10-
use std::cmp::max;
11-
// split data into regular expression and actual input to search through
12-
let len = data.chars().count();
13-
let split_off_point = max(split_point, 1) % len as usize;
14-
let char_index = data.char_indices().nth(split_off_point);
15-
if let Some((char_index, _)) = char_index {
16-
let (pattern, input) = data.split_at(char_index);
17-
if let Ok(re) = regex::Regex::new(pattern) {
18-
re.is_match(input);
19-
}
20-
}
4+
fuzz_target!(|data: (&str, &str)| {
5+
let (pattern, input) = data;
6+
7+
if let Ok(re) = regex::Regex::new(pattern) {
8+
re.is_match(input);
219
}
2210
});

0 commit comments

Comments
 (0)