about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2022-12-28 17:40:56 +0100
committervanhauser-thc <vh@thc.org>2022-12-28 17:40:56 +0100
commite847b9948daba83257a665d936d83cfd9004e2ae (patch)
tree89c7fd2fb5ac6d9c8a9f3a82f6e47bf4bd2fde86
parent342081d5ee367f473df3fc34c55edb5df7e42d0f (diff)
downloadafl++-e847b9948daba83257a665d936d83cfd9004e2ae.tar.gz
prevent weighting < 1
-rw-r--r--src/afl-fuzz-queue.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index d8dbdfbe..5017c37c 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -51,13 +51,14 @@ double compute_weight(afl_state_t *afl, struct queue_entry *q,
   if (likely(afl->schedule >= FAST && afl->schedule <= RARE)) {
 
     u32 hits = afl->n_fuzz[q->n_fuzz_entry];
-    if (likely(hits)) { weight *= log10(hits) + 1; }
+    if (likely(hits)) { weight *= (log10(hits) + 1); }
 
   }
 
   if (likely(afl->schedule < RARE)) { weight *= (avg_exec_us / q->exec_us); }
   weight *= (log(q->bitmap_size) / avg_bitmap_size);
   weight *= (1 + (q->tc_ref / avg_top_size));
+  if (unlikely(weight < 1.0)) { weight = 1.0; }
   if (unlikely(q->favored)) { weight *= 5; }
   if (unlikely(!q->was_fuzzed)) { weight *= 2; }