diff --git a/libafl/src/bolts/tuples.rs b/libafl/src/bolts/tuples.rs index 41df01bb77..2cd2d51d9e 100644 --- a/libafl/src/bolts/tuples.rs +++ b/libafl/src/bolts/tuples.rs @@ -181,6 +181,7 @@ where } } +#[macro_export] macro_rules! tuple_for_each { ($fn_name:ident, $trait_name:path, $tuple_name:ident, $body:expr) => { mod $fn_name { @@ -211,6 +212,7 @@ macro_rules! tuple_for_each { }; } +#[macro_export] macro_rules! tuple_for_each_mut { ($fn_name:ident, $trait_name:path, $tuple_name:ident, $body:expr) => { mod $fn_name { diff --git a/libafl/src/corpus/testcase.rs b/libafl/src/corpus/testcase.rs index 7dabd96733..d43812d8b3 100644 --- a/libafl/src/corpus/testcase.rs +++ b/libafl/src/corpus/testcase.rs @@ -2,7 +2,7 @@ //! It will contain a respective input, and metadata. use alloc::string::String; -use core::{convert::Into, default::Default, option::Option}; +use core::{convert::Into, default::Default, option::Option, time::Duration}; use serde::{Deserialize, Serialize}; use crate::{ @@ -26,6 +26,8 @@ where fitness: u32, /// Map of metadatas associated with this testcase metadatas: SerdeAnyMap, + /// Time needed to execute the input + exec_time: Option, } /// Impl of a testcase @@ -141,6 +143,7 @@ where filename: None, fitness: 0, metadatas: SerdeAnyMap::new(), + exec_time: None, } } @@ -152,6 +155,7 @@ where filename: Some(filename), fitness: 0, metadatas: SerdeAnyMap::new(), + exec_time: None, } } @@ -162,6 +166,7 @@ where filename: None, fitness: 0, metadatas: SerdeAnyMap::new(), + exec_time: None, } } } diff --git a/libafl/src/inputs/bytes.rs b/libafl/src/inputs/bytes.rs index 0726df7de6..b622a002f7 100644 --- a/libafl/src/inputs/bytes.rs +++ b/libafl/src/inputs/bytes.rs @@ -5,7 +5,7 @@ use alloc::{borrow::ToOwned, rc::Rc, vec::Vec}; use core::{cell::RefCell, convert::From}; use serde::{Deserialize, Serialize}; -use crate::inputs::{HasBytesVec, HasTargetBytes, Input, TargetBytes}; +use crate::inputs::{HasBytesVec, HasTargetBytes, HasLen, Input, TargetBytes}; /// A bytes input is the basic input #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq)] @@ -42,6 +42,13 @@ impl HasTargetBytes for BytesInput { } } +impl HasLen for BytesInput { + #[inline] + fn len(&self) -> usize { + self.bytes.len() + } +} + impl From> for BytesInput { fn from(bytes: Vec) -> Self { Self::new(bytes) diff --git a/libafl/src/inputs/mod.rs b/libafl/src/inputs/mod.rs index 22e1060c30..09a62f698a 100644 --- a/libafl/src/inputs/mod.rs +++ b/libafl/src/inputs/mod.rs @@ -33,7 +33,9 @@ pub trait Input: Clone + serde::Serialize + serde::de::DeserializeOwned + Debug #[cfg(not(feature = "std"))] /// Write this input to the file fn to_file

(&self, _path: P) -> Result<(), Error> -where { + where + P: AsRef, + { Err(Error::NotImplemented("Not suppored in no_std".into())) } @@ -52,7 +54,9 @@ where { /// Write this input to the file #[cfg(not(feature = "std"))] fn from_file

(_path: P) -> Result -where { + where + P: AsRef, + { Err(Error::NotImplemented("Not suppored in no_std".into())) } } @@ -96,3 +100,10 @@ pub trait HasBytesVec { /// The internal bytes map (as mutable borrow) fn bytes_mut(&mut self) -> &mut Vec; } + +/// Has a length field +pub trait HasLen { + /// The lenght + fn len(&self) -> usize; +} +