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