merged
This commit is contained in:
parent
0365bdac7a
commit
8f5b33ca47
@ -91,6 +91,9 @@ const LLMP_PAGE_HEADER_LEN: usize = size_of::<LlmpPage>();
|
|||||||
/// Message hook type
|
/// Message hook type
|
||||||
pub type LlmpMsgHookFn = unsafe fn(client_id: u32, msg: *mut LlmpMsg) -> LlmpMsgHookResult;
|
pub type LlmpMsgHookFn = unsafe fn(client_id: u32, msg: *mut LlmpMsg) -> LlmpMsgHookResult;
|
||||||
|
|
||||||
|
/// TAGs used thorughout llmp
|
||||||
|
pub type Tag = u32;
|
||||||
|
|
||||||
/// Sending end on a (unidirectional) sharedmap channel
|
/// Sending end on a (unidirectional) sharedmap channel
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LlmpSender {
|
pub struct LlmpSender {
|
||||||
@ -139,7 +142,7 @@ pub struct LlmpSharedMap {
|
|||||||
#[repr(C, packed)]
|
#[repr(C, packed)]
|
||||||
pub struct LlmpMsg {
|
pub struct LlmpMsg {
|
||||||
/// A tag
|
/// A tag
|
||||||
pub tag: u32,
|
pub tag: Tag,
|
||||||
/// Sender of this messge
|
/// Sender of this messge
|
||||||
pub sender: u32,
|
pub sender: u32,
|
||||||
/// The message ID, unique per page
|
/// The message ID, unique per page
|
||||||
@ -489,7 +492,7 @@ impl LlmpSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Allocates a message of the given size, tags it, and sends it off.
|
/// Allocates a message of the given size, tags it, and sends it off.
|
||||||
pub fn send_buf(&mut self, tag: u32, buf: &[u8]) -> Result<(), AflError> {
|
pub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), AflError> {
|
||||||
// Make sure we don't reuse already allocated tags
|
// Make sure we don't reuse already allocated tags
|
||||||
if tag == LLMP_TAG_NEW_SHM_CLIENT
|
if tag == LLMP_TAG_NEW_SHM_CLIENT
|
||||||
|| tag == LLMP_TAG_END_OF_PAGE
|
|| tag == LLMP_TAG_END_OF_PAGE
|
||||||
@ -867,7 +870,7 @@ impl LlmpBroker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Broadcasts the given buf to all lients
|
/// Broadcasts the given buf to all lients
|
||||||
fn send_buf(&mut self, tag: u32, buf: &[u8]) -> Result<(), AflError> {
|
pub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), AflError> {
|
||||||
self.llmp_out.send_buf(tag, buf)
|
self.llmp_out.send_buf(tag, buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -915,7 +918,7 @@ impl LlmpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Allocates a message of the given size, tags it, and sends it off.
|
/// Allocates a message of the given size, tags it, and sends it off.
|
||||||
pub fn send_buf(&mut self, tag: u32, buf: &[u8]) -> Result<(), AflError> {
|
pub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), AflError> {
|
||||||
self.llmp_out.send_buf(tag, buf)
|
self.llmp_out.send_buf(tag, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,6 +376,12 @@ where
|
|||||||
phantom: PhantomData<(C, E, I, R)>,
|
phantom: PhantomData<(C, E, I, R)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Forward this to the client
|
||||||
|
const LLMP_TAG_EVENT_TO_CLIENT: llmp::Tag = 0x2C11E471;
|
||||||
|
/// Only handle this in the broker
|
||||||
|
const LLMP_TAG_EVENT_TO_BROKER: llmp::Tag = 0x2B80438;
|
||||||
|
const LLMP_TAG_EVENT_TO_BOTH: llmp::Tag = 0x2B0741;
|
||||||
|
|
||||||
/// Eventmanager for multi-processed application
|
/// Eventmanager for multi-processed application
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub struct LlmpClientEventManager<C, E, I, R>
|
pub struct LlmpClientEventManager<C, E, I, R>
|
||||||
@ -406,8 +412,9 @@ where
|
|||||||
state: &mut State<I, R>,
|
state: &mut State<I, R>,
|
||||||
corpus: &mut C,
|
corpus: &mut C,
|
||||||
) -> Result<(), AflError> {
|
) -> Result<(), AflError> {
|
||||||
// TODO let serialized = postcard::to_vec(&event)?;
|
let serialized = postcard::to_allocvec(&event)?;
|
||||||
// self.llmp_broker.send_buf(&serialized)?;
|
self.llmp_broker
|
||||||
|
.send_buf(LLMP_TAG_EVENT_TO_CLIENT, &serialized)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ pub use bytes::BytesInput;
|
|||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use core::clone::Clone;
|
use core::clone::Clone;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
@ -22,9 +23,8 @@ pub trait Input: Clone + serde::Serialize + serde::de::DeserializeOwned {
|
|||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let mut file = File::create(path)?;
|
let mut file = File::create(path)?;
|
||||||
let v = bincode::serialize(&self)
|
let serialized = postcard::to_allocvec(self)?;
|
||||||
.map_err(|_| AflError::Unknown("cannot serialize".to_string()))?;
|
file.write_all(&serialized);
|
||||||
file.write_all(v.as_slice())?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,11 +41,10 @@ where {
|
|||||||
where
|
where
|
||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let mut file = File::open(path).map_err(AflError::File)?;
|
let mut file = File::open(path)?;
|
||||||
let mut bytes: Vec<u8> = vec![];
|
let mut bytes: Vec<u8> = vec![];
|
||||||
file.read_to_end(&mut bytes).map_err(AflError::File)?;
|
file.read_to_end(&mut bytes)?;
|
||||||
bincode::deserialize::<Self>(&bytes)
|
Ok(postcard::from_bytes(&bytes)?)
|
||||||
.map_err(|_| AflError::Unknown("cannot deserialize".to_string()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Write this input to the file
|
/// Write this input to the file
|
||||||
|
@ -69,6 +69,13 @@ impl fmt::Display for AflError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stringify the postcard serializer error
|
||||||
|
impl From<postcard::Error> for AflError {
|
||||||
|
fn from(err: postcard::Error) -> Self {
|
||||||
|
Self::Serialize(err.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create an AFL Error from io Error
|
/// Create an AFL Error from io Error
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl From<io::Error> for AflError {
|
impl From<io::Error> for AflError {
|
||||||
|
@ -16,7 +16,7 @@ use crate::serde_anymap::{Ptr, PtrMut};
|
|||||||
|
|
||||||
/// A Mutational stage is the stage in a fuzzing run that mutates inputs.
|
/// A Mutational stage is the stage in a fuzzing run that mutates inputs.
|
||||||
/// Mutational stages will usually have a range of mutations that are
|
/// Mutational stages will usually have a range of mutations that are
|
||||||
/// being applied to the input one by one.
|
/// being applied to the input one by one, between executions.
|
||||||
pub trait MutationalStage<M, EM, E, C, I, R>: Stage<EM, E, C, I, R>
|
pub trait MutationalStage<M, EM, E, C, I, R>: Stage<EM, E, C, I, R>
|
||||||
where
|
where
|
||||||
M: Mutator<C, I, R>,
|
M: Mutator<C, I, R>,
|
||||||
@ -56,7 +56,6 @@ where
|
|||||||
|
|
||||||
let fitness = state.evaluate_input(&input_mut, engine.executor_mut())?;
|
let fitness = state.evaluate_input(&input_mut, engine.executor_mut())?;
|
||||||
|
|
||||||
// TODO post exec on the testcase, like post_exec(testcase_maybe, i as i32)
|
|
||||||
self.mutator_mut()
|
self.mutator_mut()
|
||||||
.post_exec(fitness, &input_mut, i as i32)?;
|
.post_exec(fitness, &input_mut, i as i32)?;
|
||||||
|
|
||||||
@ -67,6 +66,7 @@ where
|
|||||||
// if needed by particular cases
|
// if needed by particular cases
|
||||||
let testcase_maybe = state.testcase_if_interesting(input_mut, fitness)?;
|
let testcase_maybe = state.testcase_if_interesting(input_mut, fitness)?;
|
||||||
if let Some(mut testcase) = testcase_maybe {
|
if let Some(mut testcase) = testcase_maybe {
|
||||||
|
// TODO decouple events manager and engine
|
||||||
manager.fire(
|
manager.fire(
|
||||||
Event::NewTestcase {
|
Event::NewTestcase {
|
||||||
sender_id: 0,
|
sender_id: 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user