• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #![no_main]
2 use libfuzzer_sys::fuzz_target;
3 
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         }
21     }
22 });
23