From 56d70accf5e7479f18a22d9d44c37ed36840dda2 Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Thu, 18 Jul 2024 11:11:37 +0200 Subject: [PATCH] Fix cmin (#2420) * fix minimizer * clp --- libafl/src/corpus/minimizer.rs | 7 +++++++ libafl/src/schedulers/mod.rs | 1 + 2 files changed, 8 insertions(+) diff --git a/libafl/src/corpus/minimizer.rs b/libafl/src/corpus/minimizer.rs index 7455622a6e..d4c3aaf381 100644 --- a/libafl/src/corpus/minimizer.rs +++ b/libafl/src/corpus/minimizer.rs @@ -99,6 +99,9 @@ where EM: EventFirer, Z: HasScheduler, { + // don't delete this else it won't work after restart + let current = *state.corpus().current(); + let cfg = Config::default(); let ctx = Context::new(&cfg); let opt = Optimize::new(&ctx); @@ -224,6 +227,10 @@ where // reverse order; if indexes are stored in a vec, we need to remove from back to front removed.sort_unstable_by(|id1, id2| id2.cmp(id1)); for id in removed { + if let Some(_cur) = current { + continue; + } + let removed = state.corpus_mut().remove(id)?; // scheduler needs to know we've removed the input, or it will continue to try // to use now-missing inputs diff --git a/libafl/src/schedulers/mod.rs b/libafl/src/schedulers/mod.rs index d501714dd3..2919858f83 100644 --- a/libafl/src/schedulers/mod.rs +++ b/libafl/src/schedulers/mod.rs @@ -48,6 +48,7 @@ where Self::State: HasCorpus, { /// Removed the given entry from the corpus at the given index + /// When you remove testcases, make sure that that testcase is not currently fuzzed one! fn on_remove( &mut self, _state: &mut Self::State,