* code cleanup * removing another unnecessary borrow * cleaning up the cleanup
This commit is contained in:
parent
2c676f0352
commit
e370e2f852
@ -43,8 +43,8 @@ impl CustomInput {
|
||||
(&mut self.byte_array).into()
|
||||
}
|
||||
|
||||
/// Returns an immutable reference to the byte array wrapped in [`Some`]
|
||||
pub fn byte_array_optional<'a>(&'a self) -> &'a [u8] {
|
||||
/// Returns an immutable reference to the byte array
|
||||
pub fn byte_array(&self) -> &[u8] {
|
||||
&self.byte_array
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ impl CustomInput {
|
||||
}
|
||||
|
||||
/// Returns an immutable reference to the optional byte array
|
||||
pub fn optional_byte_array_optional<'a>(&'a self) -> Option<&'a [u8]> {
|
||||
pub fn optional_byte_array(&self) -> Option<&[u8]> {
|
||||
self.optional_byte_array.as_deref()
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,10 @@ use libafl_bolts::{
|
||||
};
|
||||
#[cfg(not(feature = "simple_interface"))]
|
||||
use {
|
||||
libafl::{
|
||||
inputs::MutVecInput,
|
||||
mutators::{
|
||||
libafl::mutators::{
|
||||
havoc_mutations::{havoc_crossover_with_corpus_mapper, havoc_mutations_no_crossover},
|
||||
mapping::{ToMappedInputFunctionMappingMutatorMapper, ToOptionMappingMutatorMapper},
|
||||
},
|
||||
},
|
||||
libafl_bolts::tuples::Map,
|
||||
};
|
||||
|
||||
@ -140,15 +137,13 @@ pub fn main() {
|
||||
#[cfg(feature = "simple_interface")]
|
||||
let (mapped_mutators, optional_mapped_mutators) = {
|
||||
// Creating mutators that will operate on input.byte_array
|
||||
let mapped_mutators = mapped_havoc_mutations(
|
||||
CustomInput::byte_array_mut,
|
||||
CustomInput::byte_array_optional,
|
||||
);
|
||||
let mapped_mutators =
|
||||
mapped_havoc_mutations(CustomInput::byte_array_mut, CustomInput::byte_array);
|
||||
|
||||
// Creating mutators that will operate on input.optional_byte_array
|
||||
let optional_mapped_mutators = optional_mapped_havoc_mutations(
|
||||
CustomInput::optional_byte_array_mut,
|
||||
CustomInput::optional_byte_array_optional,
|
||||
CustomInput::optional_byte_array,
|
||||
);
|
||||
(mapped_mutators, optional_mapped_mutators)
|
||||
};
|
||||
@ -156,23 +151,16 @@ pub fn main() {
|
||||
#[cfg(not(feature = "simple_interface"))]
|
||||
let (mapped_mutators, optional_mapped_mutators) = {
|
||||
// Creating mutators that will operate on input.byte_array
|
||||
// For now, due to a limitation in lifetime management (see the MappedInput trait),
|
||||
// the types have to be partially specified
|
||||
let mapped_mutators = havoc_mutations_no_crossover()
|
||||
.merge(havoc_crossover_with_corpus_mapper(
|
||||
&CustomInput::byte_array_optional,
|
||||
))
|
||||
.map(ToMappedInputFunctionMappingMutatorMapper::<
|
||||
_,
|
||||
MutVecInput<'_>,
|
||||
>::new(CustomInput::byte_array_mut));
|
||||
.merge(havoc_crossover_with_corpus_mapper(CustomInput::byte_array))
|
||||
.map(ToMappedInputFunctionMappingMutatorMapper::new(
|
||||
CustomInput::byte_array_mut,
|
||||
));
|
||||
|
||||
// Creating mutators that will operate on input.optional_byte_array
|
||||
// For now, due to a limitation in lifetime management (see the MappedInput trait),
|
||||
// the types have to be partially specified
|
||||
let optional_mapped_mutators = havoc_mutations_no_crossover()
|
||||
.merge(havoc_crossover_with_corpus_mapper(
|
||||
&CustomInput::optional_byte_array_optional,
|
||||
CustomInput::optional_byte_array,
|
||||
))
|
||||
.map(ToOptionMappingMutatorMapper)
|
||||
.map(ToMappedInputFunctionMappingMutatorMapper::new(
|
||||
|
@ -201,9 +201,11 @@ pub fn havoc_crossover<I>() -> HavocCrossoverType<I> {
|
||||
}
|
||||
|
||||
/// Get the mutations that compose the Havoc mutator's crossover strategy with custom corpus extraction logic
|
||||
pub fn havoc_crossover_with_corpus_mapper<F, O>(input_mapper: F) -> MappedHavocCrossoverType<F, O>
|
||||
pub fn havoc_crossover_with_corpus_mapper<F, IO, O>(
|
||||
input_mapper: F,
|
||||
) -> MappedHavocCrossoverType<F, O>
|
||||
where
|
||||
F: Clone,
|
||||
F: Clone + Fn(IO) -> O,
|
||||
{
|
||||
tuple_list!(
|
||||
MappedCrossoverInsertMutator::new(input_mapper.clone()),
|
||||
|
Loading…
x
Reference in New Issue
Block a user