diff --git a/afl/src/events/mod.rs b/afl/src/events/mod.rs index 8465d4766f..f292bafdc7 100644 --- a/afl/src/events/mod.rs +++ b/afl/src/events/mod.rs @@ -176,9 +176,8 @@ where } } - /// Client fun -fn handle_in_client ( +fn handle_in_client( event: Event, state: &mut State, corpus: &mut C, @@ -206,14 +205,13 @@ where state.add_if_interesting(corpus, input, interestingness)?; Ok(()) } - _ => Err(AflError::Unknown( - format!("Received illegal message that message should not have arrived: {:?}.", event), - )), + _ => Err(AflError::Unknown(format!( + "Received illegal message that message should not have arrived: {:?}.", + event + ))), } } - - pub trait EventManager where C: Corpus, @@ -228,7 +226,11 @@ where /// Lookup for incoming events and process them. /// Return the number of processes events or an error - fn process(&mut self, state: &mut State, corpus: &mut C) -> Result; + fn process( + &mut self, + state: &mut State, + corpus: &mut C, + ) -> Result; /// the client stat, mutable fn client_stats_mut(&mut self) -> &mut Vec; @@ -268,11 +270,11 @@ where match event { Event::LoadInitial { sender_id: _, - phantom: _, + phantom: _, } => { self.corpus_size_inc(); Ok(BrokerEventResult::Handled) - }, + } Event::NewTestcase { sender_id: _, input: _, @@ -297,9 +299,7 @@ where // TODO: The stats buffer should be added on client add. let client_stat_count = self.client_stats().len(); for _ in client_stat_count..(*sender_id + 1) as usize { - self.client_stats_mut().push(ClientStats { - executions: 0, - }) + self.client_stats_mut().push(ClientStats { executions: 0 }) } let mut stat = &mut self.client_stats_mut()[*sender_id as usize]; stat.executions = *executions as u64; @@ -398,7 +398,9 @@ where corpus: &mut C, ) -> Result { let count = self.events.len(); - self.events.drain(..).try_for_each(|event| handle_in_client(event, state, corpus))?; + self.events + .drain(..) + .try_for_each(|event| handle_in_client(event, state, corpus))?; Ok(count) } @@ -475,7 +477,8 @@ where } #[cfg(feature = "std")] -impl EventManager for LlmpEventManager +impl EventManager + for LlmpEventManager where C: Corpus, E: Executor, @@ -500,7 +503,7 @@ where ) -> Result { // TODO: Get around local event copy by moving handle_in_client Ok(match &mut self.llmp { - llmp::LlmpConnection::IsClient {client} => { + llmp::LlmpConnection::IsClient { client } => { let mut count = 0; loop { match client.recv_buf()? { @@ -511,11 +514,11 @@ where let event: Event = postcard::from_bytes(event_buf)?; handle_in_client(event, state, corpus)?; count += 1; - }, + } None => break count, } } - }, + } _ => { dbg!("Skipping process in broker"); 0 @@ -549,7 +552,6 @@ where #[cfg(test)] mod tests { - use crate::inputs::bytes::BytesInput; use crate::observers::StdMapObserver; use crate::tuples::{tuple_list, MatchNameAndType, Named};