From 1c2df5b28ee1c62050d9141b72911c33310900ec Mon Sep 17 00:00:00 2001 From: Addison Crump Date: Wed, 31 May 2023 16:39:27 +0200 Subject: [PATCH] use corpus rejection to dissuade the use of large inputs --- fuzz/fuzz_targets/fuzz_regex_match.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_regex_match.rs b/fuzz/fuzz_targets/fuzz_regex_match.rs index 8b3453934..56f778db6 100644 --- a/fuzz/fuzz_targets/fuzz_regex_match.rs +++ b/fuzz/fuzz_targets/fuzz_regex_match.rs @@ -1,9 +1,9 @@ #![no_main] -use libfuzzer_sys::fuzz_target; +use libfuzzer_sys::{fuzz_target, Corpus}; -fuzz_target!(|data: &[u8]| { +fuzz_target!(|data: &[u8]| -> Corpus { if data.len() < 2 { - return; + return Corpus::Reject; } let split_point = data[0] as usize; if let Ok(data) = std::str::from_utf8(&data[1..]) { @@ -21,7 +21,7 @@ fuzz_target!(|data: &[u8]| { // be done about them. Unicode word boundaries in the PikeVM are // slow. It is what it is. if input.len() >= 8 * (1 << 10) { - return; + return Corpus::Reject; } let result = regex::RegexBuilder::new(pattern).size_limit(1 << 18).build(); @@ -30,4 +30,5 @@ fuzz_target!(|data: &[u8]| { } } } + Corpus::Keep });