Merge branch 'main' of github.com:AFLplusplus/libAFLrs into main

This commit is contained in:
Andrea Fioraldi 2020-12-11 11:09:04 +01:00
commit 9dae6b0516
3 changed files with 17 additions and 1 deletions

View File

@ -69,6 +69,7 @@ const INTERESTING_32: [i32; 27] = [
2147483647,
];
#[inline]
fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) {
debug_assert!(from + len <= data.len());
debug_assert!(to + len <= data.len());
@ -76,6 +77,7 @@ fn self_mem_move(data: &mut [u8], from: usize, to: usize, len: usize) {
unsafe { core::ptr::copy(ptr.offset(from as isize), ptr.offset(to as isize), len) }
}
#[inline]
fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) {
debug_assert!(from + len <= src.len());
debug_assert!(to + len <= dst.len());
@ -90,6 +92,7 @@ fn mem_move(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usize) {
}
}
#[inline]
fn mem_set(data: &mut [u8], from: usize, len: usize, val: u8) {
debug_assert!(from + len <= data.len());
let ptr = data.as_mut_ptr();

View File

@ -13,7 +13,6 @@ use crate::AflError;
/// Observers observe different information about the target.
/// They can then be used by various sorts of feedback.
pub trait Observer: SerdeAny + 'static {
/// The testcase finished execution, calculate any changes.
#[inline]
fn flush(&mut self) -> Result<(), AflError> {
@ -82,10 +81,12 @@ impl<T> Observer for StdMapObserver<T>
where
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
{
#[inline]
fn reset(&mut self) -> Result<(), AflError> {
self.reset_map()
}
#[inline]
fn name(&self) -> &String {
&self.name
}
@ -95,9 +96,12 @@ impl<T> SerdeAny for StdMapObserver<T>
where
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
{
#[inline]
fn as_any(&self) -> &dyn Any {
self
}
#[inline]
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
@ -107,22 +111,27 @@ impl<T> MapObserver<T> for StdMapObserver<T>
where
T: Default + Copy + 'static + serde::Serialize + serde::de::DeserializeOwned,
{
#[inline]
fn map(&self) -> &[T] {
self.map.as_slice()
}
#[inline]
fn map_mut(&mut self) -> &mut [T] {
self.map.as_mut_slice()
}
#[inline]
fn initial(&self) -> T {
self.initial
}
#[inline]
fn initial_mut(&mut self) -> &mut T {
&mut self.initial
}
#[inline]
fn set_initial(&mut self, initial: T) {
self.initial = initial
}

View File

@ -34,6 +34,7 @@ where
/// Gets the number of iterations this mutator should run for.
/// This call uses internal mutability, so it may change for each call
#[inline]
fn iterations(&mut self, rand: &mut R) -> usize {
1 + rand.below(128) as usize
}
@ -106,11 +107,13 @@ where
R: Rand,
{
/// The mutator, added to this stage
#[inline]
fn mutator(&self) -> &M {
&self.mutator
}
/// The list of mutators, added to this stage (as mutable ref)
#[inline]
fn mutator_mut(&mut self) -> &mut M {
&mut self.mutator
}
@ -125,6 +128,7 @@ where
I: Input,
R: Rand,
{
#[inline]
fn perform(
&mut self,
rand: &mut R,