From 1089c935771c9cb22f6bac0535b85ae3d5823bb6 Mon Sep 17 00:00:00 2001 From: Max Ammann Date: Mon, 24 May 2021 14:03:32 +0200 Subject: [PATCH] Make load_initial_inputs work for arbitrary inputs (#121) --- libafl/src/state/mod.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/libafl/src/state/mod.rs b/libafl/src/state/mod.rs index 737136d4b7..5b4c204296 100644 --- a/libafl/src/state/mod.rs +++ b/libafl/src/state/mod.rs @@ -23,9 +23,6 @@ use crate::{ Error, }; -#[cfg(feature = "std")] -use crate::inputs::bytes::BytesInput; - /// The maximum size of a testcase pub const DEFAULT_MAX_SIZE: usize = 1_048_576; @@ -349,12 +346,13 @@ where } #[cfg(feature = "std")] -impl StdState +impl StdState where - C: Corpus, + C: Corpus, + I: Input, R: Rand, FT: FeedbackStatesTuple, - SC: Corpus, + SC: Corpus, { /// loads inputs from a directory fn load_from_directory( @@ -365,7 +363,7 @@ where in_dir: &Path, ) -> Result<(), Error> where - Z: Evaluator, + Z: Evaluator, { for entry in fs::read_dir(in_dir)? { let entry = entry?; @@ -380,8 +378,7 @@ where if attr.is_file() && attr.len() > 0 { println!("Loading file {:?} ...", &path); - let bytes = fs::read(&path)?; - let input = BytesInput::new(bytes); + let input = I::from_file(&path)?; let (is_interesting, _) = fuzzer.evaluate_input(self, executor, manager, input)?; if !is_interesting { println!("File {:?} was not interesting, skipped.", &path); @@ -403,8 +400,8 @@ where in_dirs: &[PathBuf], ) -> Result<(), Error> where - Z: Evaluator, - EM: EventManager, + Z: Evaluator, + EM: EventManager, { for in_dir in in_dirs { self.load_from_directory(fuzzer, executor, manager, in_dir)?;