Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fuzzers/baby_fuzzer_minimizing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ pub fn main() -> Result<(), Error> {
.expect("Failed to generate the initial corpus");

// Setup a mutational stage with a basic bytes mutator
let mutator = StdScheduledMutator::new(havoc_mutations());
let minimizer = StdScheduledMutator::new(havoc_mutations());
let mutator = StdScheduledMutator::new(havoc_mutations::<BytesInput>());
let minimizer = StdScheduledMutator::new(havoc_mutations::<BytesInput>());
let mut stages = tuple_list!(
StdMutationalStage::new(mutator),
StdTMinMutationalStage::new(minimizer, factory, 128)
Expand All @@ -121,7 +121,7 @@ pub fn main() -> Result<(), Error> {

let mut mgr = SimpleEventManager::new(mon);

let minimizer = StdScheduledMutator::new(havoc_mutations());
let minimizer = StdScheduledMutator::new(havoc_mutations::<BytesInput>());
let mut stages = tuple_list!(StdTMinMutationalStage::new(
minimizer,
CrashFeedback::new(),
Expand Down
4 changes: 2 additions & 2 deletions libafl/src/corpus/testcase.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The testcase is a struct embedded in each corpus.
//! The [`Testcase`] is a struct embedded in each [`Corpus`].
//! It will contain a respective input, and metadata.

use alloc::string::String;
Expand Down Expand Up @@ -34,7 +34,7 @@ pub trait HasTestcase: UsesInput {
) -> Result<RefMut<Testcase<<Self as UsesInput>::Input>>, Error>;
}

/// An entry in the Testcase Corpus
/// An entry in the [`Testcase`] Corpus
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(bound = "I: serde::de::DeserializeOwned")]
pub struct Testcase<I>
Expand Down
29 changes: 26 additions & 3 deletions libafl/src/inputs/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use libafl_bolts::{fs::write_file_atomic, Error};
use libafl_bolts::{ownedref::OwnedSlice, HasLen};
use serde::{Deserialize, Serialize};

use crate::inputs::{HasBytesVec, HasTargetBytes, Input};
use crate::inputs::{HasMutatorBytes, HasTargetBytes, Input};

/// A bytes input is the basic input
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -61,16 +61,39 @@ impl From<BytesInput> for Rc<RefCell<BytesInput>> {
}
}

impl HasBytesVec for BytesInput {
impl HasMutatorBytes for BytesInput {
#[inline]
fn bytes(&self) -> &[u8] {
&self.bytes
}

#[inline]
fn bytes_mut(&mut self) -> &mut Vec<u8> {
fn bytes_mut(&mut self) -> &mut [u8] {
&mut self.bytes
}

fn resize(&mut self, new_len: usize, value: u8) {
self.bytes.resize(new_len, value);
}

fn extend<'a, I: IntoIterator<Item = &'a u8>>(&mut self, iter: I) {
Extend::extend(&mut self.bytes, iter);
}

fn splice<R, I>(&mut self, range: R, replace_with: I) -> alloc::vec::Splice<'_, I::IntoIter>
where
R: core::ops::RangeBounds<usize>,
I: IntoIterator<Item = u8>,
{
self.bytes.splice(range, replace_with)
}

fn drain<R>(&mut self, range: R) -> alloc::vec::Drain<'_, u8>
where
R: core::ops::RangeBounds<usize>,
{
self.bytes.drain(range)
}
}

impl HasTargetBytes for BytesInput {
Expand Down
Loading