diff --git a/afl/src/corpus/mod.rs b/afl/src/corpus/mod.rs index c2688e00fc..92d047adf4 100644 --- a/afl/src/corpus/mod.rs +++ b/afl/src/corpus/mod.rs @@ -149,12 +149,6 @@ where I: Input, R: Rand, { - /// Returns the number of elements - #[inline] - fn count(&self) -> usize { - self.entries().len() - } - /// Gets the next entry #[inline] fn next(&mut self, rand: &mut R) -> Result<(&RefCell>, usize), AflError> { diff --git a/afl/src/engines/mod.rs b/afl/src/engines/mod.rs index b17c9e05a9..483eeb3d2b 100644 --- a/afl/src/engines/mod.rs +++ b/afl/src/engines/mod.rs @@ -3,6 +3,7 @@ use core::fmt::Debug; use core::marker::PhantomData; use serde::{Deserialize, Serialize}; +#[cfg(feature = "std")] use std::{ fs, path::{Path, PathBuf}, @@ -13,6 +14,7 @@ use crate::events::EventManager; use crate::executors::{Executor, ExecutorsTuple, HasObservers}; use crate::feedbacks::FeedbacksTuple; use crate::generators::Generator; +#[cfg(feature = "std")] use crate::inputs::bytes::BytesInput; use crate::inputs::Input; use crate::observers::ObserversTuple; @@ -50,6 +52,7 @@ where phantom: PhantomData<(I, R, OT)>, } +#[cfg(feature = "std")] impl State where R: Rand, diff --git a/afl/src/events/mod.rs b/afl/src/events/mod.rs index 163b6d9670..b4e95595e5 100644 --- a/afl/src/events/mod.rs +++ b/afl/src/events/mod.rs @@ -5,11 +5,8 @@ use alloc::string::{String, ToString}; use alloc::vec::Vec; use core::time::Duration; use core::{marker::PhantomData, time}; -#[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -use shmem::AflShmem; -#[cfg(feature = "std")] use self::{ llmp::{LlmpClient, Tag}, shmem::ShMem, @@ -19,11 +16,12 @@ use crate::executors::Executor; use crate::feedbacks::FeedbacksTuple; use crate::inputs::Input; use crate::observers::ObserversTuple; -#[cfg(feature = "std")] use crate::serde_anymap::Ptr; use crate::utils::Rand; use crate::AflError; use crate::{engines::State, utils}; +#[cfg(feature = "std")] +use shmem::AflShmem; #[derive(Debug, Copy, Clone)] /// Indicate if an event worked or not @@ -533,7 +531,6 @@ where } } -#[cfg(feature = "std")] #[derive(Serialize, Deserialize)] #[serde(bound = "I: serde::de::DeserializeOwned")] pub enum LLMPEventKind<'a, I> @@ -570,7 +567,6 @@ where },*/ } -#[cfg(feature = "std")] #[derive(Serialize, Deserialize)] #[serde(bound = "I: serde::de::DeserializeOwned")] pub struct LLMPEvent<'a, I> @@ -581,7 +577,6 @@ where kind: LLMPEventKind<'a, I>, } -#[cfg(feature = "std")] impl<'a, I> Event for LLMPEvent<'a, I> where I: Input, @@ -652,6 +647,8 @@ where message, phantom: _, } => { + let (_, _) = (severity_level, message); + #[cfg(feature = "std")] println!("[LOG {}]: {}", severity_level, message); Ok(BrokerEventResult::Handled) } //_ => Ok(BrokerEventResult::Forward), @@ -699,13 +696,10 @@ where } } -#[cfg(feature = "std")] /// Forward this to the client const _LLMP_TAG_EVENT_TO_CLIENT: llmp::Tag = 0x2C11E471; -#[cfg(feature = "std")] /// Only handle this in the broker const _LLMP_TAG_EVENT_TO_BROKER: llmp::Tag = 0x2B80438; -#[cfg(feature = "std")] /// Handle in both const LLMP_TAG_EVENT_TO_BOTH: llmp::Tag = 0x2B0741; @@ -726,6 +720,7 @@ where phantom: PhantomData<(C, E, OT, FT, I, R)>, } +#[cfg(feature = "std")] impl LlmpEventManager where C: Corpus, @@ -740,9 +735,9 @@ where /// Create llmp on a port /// If the port is not yet bound, it will act as broker /// Else, it will act as client. - pub fn new_on_port_std(stats: ST) -> Result { + pub fn new_on_port_std(port: u16, stats: ST) -> Result { Ok(Self { - llmp: llmp::LlmpConnection::on_port(1337)?, + llmp: llmp::LlmpConnection::on_port(port)?, stats: stats, phantom: PhantomData, }) @@ -829,7 +824,6 @@ where } } -#[cfg(feature = "std")] impl EventManager for LlmpEventManager where @@ -871,6 +865,7 @@ where } } _ => { + #[cfg(feature = "std")] dbg!("Skipping process in broker"); 0 } @@ -926,7 +921,6 @@ where } } -#[cfg(feature = "std")] #[cfg(test)] mod tests { @@ -938,6 +932,7 @@ mod tests { use crate::tuples::{tuple_list, MatchNameAndType, Named}; static mut MAP: [u32; 4] = [0; 4]; + #[test] fn test_event_serde() { let obv = StdMapObserver::new("test", unsafe { &mut MAP }); @@ -969,7 +964,7 @@ mod tests { let test_observer = o.match_name_type::>("test").unwrap(); assert_eq!("test", test_observer.name()); } - _ => panic!("mistmatch".to_string()), + _ => panic!("mistmatch"), }; } } diff --git a/afl/src/events/shmem.rs b/afl/src/events/shmem.rs index bcd92b269c..ade6e25979 100644 --- a/afl/src/events/shmem.rs +++ b/afl/src/events/shmem.rs @@ -1,7 +1,7 @@ //! A generic sharememory region to be used by any functions (queues or feedbacks // too.) -use alloc::string::String; +use alloc::string::{String, ToString}; #[cfg(feature = "std")] use core::{mem::size_of, slice}; #[cfg(feature = "std")] @@ -277,6 +277,8 @@ unsafe fn afl_shmem_by_str(shm: *mut AflShmem, shm_str: &CStr, map_size: usize) #[cfg(test)] mod tests { + + #[cfg(feature = "std")] use super::{AflShmem, ShMem}; #[cfg(feature = "std")]