Skip to content

Commit

Permalink
Add check for if mutation succeeded, else skip processing (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump authored May 14, 2023
1 parent 659e91f commit 1da6214
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions libafl/src/stages/mutational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
fuzzer::Evaluator,
inputs::Input,
mark_feature_time,
mutators::Mutator,
mutators::{MutationResult, Mutator},
stages::Stage,
start_timer,
state::{HasClientPerfMonitor, HasCorpus, HasRand, UsesState},
Expand Down Expand Up @@ -127,9 +127,13 @@ where
let mut input = input.clone();

start_timer!(state);
self.mutator_mut().mutate(state, &mut input, i as i32)?;
let mutated = self.mutator_mut().mutate(state, &mut input, i as i32)?;
mark_feature_time!(state, PerfFeature::Mutate);

if mutated == MutationResult::Skipped {
continue;
}

// Time is measured directly the `evaluate_input` function
let (untransformed, post) = input.try_transform_into(state)?;
let (_, corpus_idx) = fuzzer.evaluate_input(state, executor, manager, untransformed)?;
Expand Down
8 changes: 6 additions & 2 deletions libafl/src/stages/tmin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
feedbacks::{Feedback, FeedbackFactory, HasObserverName},
inputs::UsesInput,
mark_feature_time,
mutators::Mutator,
mutators::{MutationResult, Mutator},
observers::{MapObserver, ObserversTuple},
schedulers::{RemovableScheduler, Scheduler},
stages::Stage,
Expand Down Expand Up @@ -97,9 +97,13 @@ where
state.set_max_size(before_len);

start_timer!(state);
self.mutator_mut().mutate(state, &mut input, i as i32)?;
let mutated = self.mutator_mut().mutate(state, &mut input, i as i32)?;
mark_feature_time!(state, PerfFeature::Mutate);

if mutated == MutationResult::Skipped {
continue;
}

let corpus_idx = if input.len() < before_len {
// run the input
let exit_kind = fuzzer.execute_input(state, executor, manager, &input)?;
Expand Down
8 changes: 6 additions & 2 deletions libafl/src/stages/tuneable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
bolts::{current_time, rands::Rand},
corpus::{Corpus, CorpusId},
impl_serdeany, mark_feature_time,
mutators::Mutator,
mutators::{MutationResult, Mutator},
stages::{
mutational::{MutatedTransform, MutatedTransformPost, DEFAULT_MUTATIONAL_MAX_ITERATIONS},
MutationalStage, Stage,
Expand Down Expand Up @@ -142,9 +142,13 @@ where
let mut input = input.clone();

start_timer!(state);
self.mutator_mut().mutate(state, &mut input, i as i32)?;
let mutated = self.mutator_mut().mutate(state, &mut input, i as i32)?;
mark_feature_time!(state, PerfFeature::Mutate);

if mutated == MutationResult::Skipped {
continue;
}

// Time is measured directly the `evaluate_input` function
let (untransformed, post) = input.try_transform_into(state)?;
let (_, corpus_idx) = fuzzer.evaluate_input(state, executor, manager, untransformed)?;
Expand Down

0 comments on commit 1da6214

Please sign in to comment.