From 98fad33deff15ac82cf3cc2bae4d9b23f10ea997 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 9 Jan 2021 22:57:30 +0100 Subject: [PATCH] const rand --- afl/Cargo.toml | 2 +- afl/src/mutators/scheduled.rs | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/afl/Cargo.toml b/afl/Cargo.toml index 012828f0fb..303573d06b 100644 --- a/afl/Cargo.toml +++ b/afl/Cargo.toml @@ -41,7 +41,7 @@ required-features = ["std"] [dependencies] tuple_list = "0.1.2" -hashbrown = { version = "0.9", features = ["serde"] } # A faster hashmap, nostd compatible +hashbrown = { version = "0.9", features = ["serde", "ahash-compile-time-rng"] } # A faster hashmap, nostd compatible libc = "0.2" # For (*nix) libc num = "*" xxhash-rust = { version = "0.8.0", features = ["xxh3"] } # xxh3 hashing for rust diff --git a/afl/src/mutators/scheduled.rs b/afl/src/mutators/scheduled.rs index b77233f716..3b2b05e314 100644 --- a/afl/src/mutators/scheduled.rs +++ b/afl/src/mutators/scheduled.rs @@ -194,23 +194,24 @@ where let num = self.scheduled.iterations(rand, input); for _ in 0..num { let idx = self.scheduled.schedule(13, rand, input); - match idx { - 0 => mutation_bitflip(self, rand, corpus, input)?, - 1 => mutation_byteflip(self, rand, corpus, input)?, - 2 => mutation_byteinc(self, rand, corpus, input)?, - 3 => mutation_bytedec(self, rand, corpus, input)?, - 4 => mutation_byteneg(self, rand, corpus, input)?, - 5 => mutation_byterand(self, rand, corpus, input)?, + let mutation = match idx { + 0 => mutation_bitflip, + 1 => mutation_byteflip, + 2 => mutation_byteinc, + 3 => mutation_bytedec, + 4 => mutation_byteneg, + 5 => mutation_byterand, - 6 => mutation_byteadd(self, rand, corpus, input)?, - 7 => mutation_wordadd(self, rand, corpus, input)?, - 8 => mutation_dwordadd(self, rand, corpus, input)?, - 9 => mutation_byteinteresting(self, rand, corpus, input)?, - 10 => mutation_wordinteresting(self, rand, corpus, input)?, - 11 => mutation_dwordinteresting(self, rand, corpus, input)?, + 6 => mutation_byteadd, + 7 => mutation_wordadd, + 8 => mutation_dwordadd, + 9 => mutation_byteinteresting, + 10 => mutation_wordinteresting, + 11 => mutation_dwordinteresting, - _ => mutation_splice(self, rand, corpus, input)?, + _ => mutation_splice, }; + mutation(self, rand, corpus, input)?; } Ok(()) }