From 04e06fc4037c2090f0baf9cc8ccf42cf2605637e Mon Sep 17 00:00:00 2001 From: Gabor Seljan Date: Thu, 6 Jan 2022 21:10:08 +0100 Subject: [PATCH] Remove test cases with a duplicate trace map --- afl-fuzz.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/afl-fuzz.c b/afl-fuzz.c index d70422d2..6ad162bc 100644 --- a/afl-fuzz.c +++ b/afl-fuzz.c @@ -3342,6 +3342,69 @@ static void perform_dry_run(char** argv) { } + /* Now we remove all entries from the queue that have a duplicate trace map. */ + + ACTF("Removing entries with a duplicate trace map..."); + + q = queue; + int duplicates = 0; + struct queue_entry* p, * dup = NULL; + + while (q) { + + if (q->cal_failed || !q->exec_cksum) { + + q = q->next; + continue; + + } + + p = q->next; + + while (p) { + + if (!p->cal_failed && p->exec_cksum == q->exec_cksum) { + + duplicates = 1; + --pending_not_fuzzed; + + // We keep the shorter file. + if (p->len >= q->len) { + dup = p; + p->was_fuzzed = 1; + } else { + dup = q; + q->was_fuzzed = 1; + } + + WARNF("Duplicate entry '%s' was marked as fuzzed.", strrchr(dup->fname, '\\') + 1); + + } + + p = p->next; + + } + + q = q->next; + + } + + if (duplicates) { + + ACTF("Recalculating max depth due to duplicates..."); + + q = queue; + max_depth = 0; + + while (q) { + + if (q->depth > max_depth) max_depth = q->depth; + q = q->next; + + } + + } + OKF("All test cases processed."); }