in memory executor first impl
This commit is contained in:
parent
89e0b01706
commit
ce9413bfa4
@ -13,7 +13,7 @@ pub trait Executor {
|
|||||||
|
|
||||||
fn run_target(&mut self) -> Result<ExitKind, AflError>;
|
fn run_target(&mut self) -> Result<ExitKind, AflError>;
|
||||||
|
|
||||||
fn place_input(&mut self, entry: Box<dyn Input>) -> Result<(), AflError>;
|
fn place_input(&mut self, input: Box<dyn Input>) -> Result<(), AflError>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,4 +23,30 @@ pub struct ExecutorBase {
|
|||||||
observers: Vec<Box<dyn Observer>>,
|
observers: Vec<Box<dyn Observer>>,
|
||||||
cur_input: Box<dyn Input>
|
cur_input: Box<dyn Input>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type HarnessFunction = fn(&dyn Executor, &[u8]) -> ExitKind;
|
||||||
|
|
||||||
|
pub struct InMemoryExecutor {
|
||||||
|
|
||||||
|
base: ExecutorBase,
|
||||||
|
harness: HarnessFunction,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Executor for InMemoryExecutor {
|
||||||
|
|
||||||
|
fn run_target(&mut self) -> Result<ExitKind, AflError> {
|
||||||
|
let bytes = self.base.cur_input.serialize();
|
||||||
|
return match bytes {
|
||||||
|
Ok(b) => Ok((self.harness)(self, b)),
|
||||||
|
Err(e) => Err(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn place_input(&mut self, input: Box<dyn Input>) -> Result<(), AflError> {
|
||||||
|
self.base.cur_input = input;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user