From 28ed6dbf35c6ee041091d582c89f1c2c3cc539c4 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 4 Feb 2021 17:25:51 +0100 Subject: [PATCH] preliminary insert token mutator --- afl/src/mutators/mutations.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/afl/src/mutators/mutations.rs b/afl/src/mutators/mutations.rs index 13fc189b15..c5e142baaf 100644 --- a/afl/src/mutators/mutations.rs +++ b/afl/src/mutators/mutations.rs @@ -483,6 +483,35 @@ where Ok(MutationResult::Mutated) } +/* +// Insert a dictionary token +pub fn mutation_tokeninsert( + mutator: &mut M, + rand: &mut R, + _: &C, + input: &mut I, +) -> Result +where + M: HasMaxSize, + I: Input + HasBytesVec, + R: Rand, +{ + if mutator.tokens.size() == 0 { return Ok(MutationResult::Skipped); } + let token = &mutator.tokens[rand.below(token.size())]; + let token_len = token.size(); + let size = input.bytes().len(); + let off = if size == 0 { + 0 + } else { + rand.below(core::cmp::min(size, (mutator.max_size() - token_len) as u64)) as usize + } as usize; + + input.bytes_mut().resize(size + token_len, 0); + mem_move(input.bytes_mut(), token, 0, off, len); + Ok(MutationResult::Mutated) +} +*/ + pub fn mutation_bytesinsert( mutator: &mut M, rand: &mut R,