diff --git a/libafl/src/feedbacks/stdio.rs b/libafl/src/feedbacks/stdio.rs index 332bf135bd..3f4998de8e 100644 --- a/libafl/src/feedbacks/stdio.rs +++ b/libafl/src/feedbacks/stdio.rs @@ -46,7 +46,7 @@ impl StdOutToMetadataFeedback { .get(&self.o_ref) .ok_or(Error::illegal_state("StdOutObserver is missing"))?; let buffer = observer - .data + .output .as_ref() .ok_or(Error::illegal_state("StdOutObserver has no stdout"))?; let stdout = String::from_utf8_lossy(buffer).into_owned(); @@ -139,7 +139,7 @@ where .get(&self.o_ref) .ok_or(Error::illegal_state("StdErrObserver is missing"))?; let buffer = observer - .data + .output .as_ref() .ok_or(Error::illegal_state("StdErrObserver has no stderr"))?; let stderr = String::from_utf8_lossy(buffer).into_owned(); diff --git a/libafl/src/observers/stdio.rs b/libafl/src/observers/stdio.rs index d98335e37d..9cb20418a1 100644 --- a/libafl/src/observers/stdio.rs +++ b/libafl/src/observers/stdio.rs @@ -71,8 +71,8 @@ use crate::{observers::Observer, Error}; /// ) -> Result /// { /// unsafe { -/// STDOUT = observers.get(&self.stdout_observer).unwrap().data.clone(); -/// STDERR = observers.get(&self.stderr_observer).unwrap().data.clone(); +/// STDOUT = observers.get(&self.stdout_observer).unwrap().output.clone(); +/// STDERR = observers.get(&self.stderr_observer).unwrap().output.clone(); /// } /// Ok(true) /// } @@ -169,58 +169,59 @@ use crate::{observers::Observer, Error}; /// ``` #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] -pub struct StreamObserver { +pub struct OutputObserver { /// The name of the observer. pub name: Cow<'static, str>, /// The captured stdout/stderr data during last execution. - pub data: Option>, + pub output: Option>, /// Phantom data to hold the stream type phantom: PhantomData, } -/// Marker traits to distinguish between stdout and stderr +/// Marker traits to mark stdout for the `OutputObserver` #[derive(Debug, Clone)] pub struct StdOutMarker; -/// Marker traits to distinguish between stdout and stderr + +/// Marker traits to mark stderr for the `OutputObserver` #[derive(Debug, Clone)] pub struct StdErrMarker; -impl StreamObserver { - /// Create a new `StreamObserver` with the given name. +impl OutputObserver { + /// Create a new `OutputObserver` with the given name. #[must_use] pub fn new(name: &'static str) -> Self { Self { name: Cow::from(name), - data: None, + output: None, phantom: PhantomData, } } /// React to new stream data pub fn observe(&mut self, data: &[u8]) { - self.data = Some(data.into()); + self.output = Some(data.into()); } } -impl Named for StreamObserver { +impl Named for OutputObserver { fn name(&self) -> &Cow<'static, str> { &self.name } } -impl Observer for StreamObserver { +impl Observer for OutputObserver { fn pre_exec_child(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> { - self.data = None; + self.output = None; Ok(()) } fn pre_exec(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> { - self.data = None; + self.output = None; Ok(()) } } /// An observer that captures stdout of a target. -pub type StdOutObserver = StreamObserver; +pub type StdOutObserver = OutputObserver; /// An observer that captures stderr of a target. -pub type StdErrObserver = StreamObserver; +pub type StdErrObserver = OutputObserver;