fix hascorpus generic
This commit is contained in:
parent
2a937eb88d
commit
9272b8b37b
@ -25,7 +25,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Mutate a given input
|
/// Mutate a given input
|
||||||
fn mutate(
|
fn mutate(
|
||||||
|
@ -70,7 +70,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Get a mutation by index
|
/// Get a mutation by index
|
||||||
fn mutation_by_idx(&self, index: usize) -> MutationFunction<I, Self, R, S>;
|
fn mutation_by_idx(&self, index: usize) -> MutationFunction<I, Self, R, S>;
|
||||||
@ -684,7 +684,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C>,
|
S: HasCorpus<C, I, R>,
|
||||||
{
|
{
|
||||||
// We don't want to use the testcase we're already using for splicing
|
// We don't want to use the testcase we're already using for splicing
|
||||||
let (other_testcase, idx) = state.corpus().random_entry(rand)?;
|
let (other_testcase, idx) = state.corpus().random_entry(rand)?;
|
||||||
|
@ -16,7 +16,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Compute the number of iterations used to apply stacked mutations
|
/// Compute the number of iterations used to apply stacked mutations
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -55,7 +55,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
mutations: Vec<MutationFunction<I, Self, R, S>>,
|
mutations: Vec<MutationFunction<I, Self, R, S>>,
|
||||||
max_size: usize,
|
max_size: usize,
|
||||||
@ -66,7 +66,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(
|
write!(
|
||||||
@ -84,7 +84,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -102,7 +102,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mutation_by_idx(&self, index: usize) -> MutationFunction<I, Self, R, S> {
|
fn mutation_by_idx(&self, index: usize) -> MutationFunction<I, Self, R, S> {
|
||||||
@ -125,7 +125,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
// Just use the default methods
|
// Just use the default methods
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn max_size(&self) -> usize {
|
fn max_size(&self) -> usize {
|
||||||
@ -153,7 +153,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Create a new StdScheduledMutator instance without mutations and corpus
|
/// Create a new StdScheduledMutator instance without mutations and corpus
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
@ -180,7 +180,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
scheduled: SM,
|
scheduled: SM,
|
||||||
phantom: PhantomData<(C, I, R, S)>,
|
phantom: PhantomData<(C, I, R, S)>,
|
||||||
@ -192,7 +192,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Mutate bytes
|
/// Mutate bytes
|
||||||
fn mutate(
|
fn mutate(
|
||||||
@ -234,7 +234,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn max_size(&self) -> usize {
|
fn max_size(&self) -> usize {
|
||||||
@ -253,7 +253,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Create a new HavocBytesMutator instance given a ScheduledMutator to wrap
|
/// Create a new HavocBytesMutator instance given a ScheduledMutator to wrap
|
||||||
pub fn new(mut scheduled: SM) -> Self {
|
pub fn new(mut scheduled: SM) -> Self {
|
||||||
@ -271,7 +271,7 @@ where
|
|||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input + HasBytesVec,
|
I: Input + HasBytesVec,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
S: HasCorpus<C> + HasMetadata,
|
S: HasCorpus<C, I, R> + HasMetadata,
|
||||||
{
|
{
|
||||||
/// Create a new HavocBytesMutator instance wrapping StdScheduledMutator
|
/// Create a new HavocBytesMutator instance wrapping StdScheduledMutator
|
||||||
pub fn new_default() -> Self {
|
pub fn new_default() -> Self {
|
||||||
|
@ -25,7 +25,12 @@ use crate::{
|
|||||||
use crate::inputs::bytes::BytesInput;
|
use crate::inputs::bytes::BytesInput;
|
||||||
|
|
||||||
/// Trait for elements offering a corpus
|
/// Trait for elements offering a corpus
|
||||||
pub trait HasCorpus<C> {
|
pub trait HasCorpus<C, I, R>
|
||||||
|
where
|
||||||
|
C: Corpus<I, R>,
|
||||||
|
I: Input,
|
||||||
|
R: Rand,
|
||||||
|
{
|
||||||
/// The testcase corpus
|
/// The testcase corpus
|
||||||
fn corpus(&self) -> &C;
|
fn corpus(&self) -> &C;
|
||||||
/// The testcase corpus (mut)
|
/// The testcase corpus (mut)
|
||||||
@ -147,7 +152,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, FT, I, R> HasCorpus<C> for State<C, FT, I, R>
|
impl<C, FT, I, R> HasCorpus<C, I, R> for State<C, FT, I, R>
|
||||||
where
|
where
|
||||||
C: Corpus<I, R>,
|
C: Corpus<I, R>,
|
||||||
I: Input,
|
I: Input,
|
||||||
|
@ -26,6 +26,7 @@ clap = "2.32.0"
|
|||||||
serde = { version = "1.0", default-features = false, features = ["alloc"] }
|
serde = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||||
postcard = { version = "0.5.1", features = ["alloc"] }
|
postcard = { version = "0.5.1", features = ["alloc"] }
|
||||||
afl = { path = "../../afl/" }
|
afl = { path = "../../afl/" }
|
||||||
|
# libc = "0.2"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "libfuzzer"
|
name = "libfuzzer"
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
|
|
||||||
|
// extern crate libc;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use std::{env, path::PathBuf};
|
use std::{env, path::PathBuf};
|
||||||
|
|
||||||
@ -163,6 +165,16 @@ fn fuzz(input: Option<Vec<PathBuf>>, broker_port: u16) -> Result<(), AflError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// TODO close fds in a rusty way
|
||||||
|
unsafe {
|
||||||
|
let null_fname = std::ffi::CString::new("/dev/null").unwrap();
|
||||||
|
let null_file = libc::open(null_fname.as_ptr(), libc::O_RDWR);
|
||||||
|
libc::dup2(null_file, 1);
|
||||||
|
libc::dup2(null_file, 2);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// in case the corpus is empty (on first run), reset
|
// in case the corpus is empty (on first run), reset
|
||||||
if state.corpus().count() < 1 {
|
if state.corpus().count() < 1 {
|
||||||
match input {
|
match input {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user