aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2023-04-08 13:00:57 +0200
committervanhauser-thc <vh@thc.org>2023-04-08 13:00:57 +0200
commitf9851dbfbbfbc013172f500099b5f4dc572c508b (patch)
tree328ed196e1153d16dbe00f54e6fdf3b2e2c426db
parentd67ee1777859b55b1660cef15fc09219fb165140 (diff)
downloadafl++-f9851dbfbbfbc013172f500099b5f4dc572c508b.tar.gz
hopefully better -z algorithm
-rw-r--r--src/afl-fuzz-queue.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index 3335e869..6fc3c743 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -75,12 +75,6 @@ double compute_weight(afl_state_t *afl, struct queue_entry *q,
weight *= (log(q->bitmap_size) / avg_bitmap_size);
weight *= (1 + (q->tc_ref / avg_top_size));
- if (unlikely(afl->prefer_new)) {
-
- weight *= (2.0 * ((1 + q->id) / afl->queued_items));
-
- }
-
if (unlikely(weight < 0.1)) { weight = 0.1; }
if (unlikely(q->favored)) { weight *= 5; }
if (unlikely(!q->was_fuzzed)) { weight *= 2; }
@@ -155,6 +149,26 @@ void create_alias_table(afl_state_t *afl) {
}
+ if (unlikely(afl->prefer_new) && afl->queued_discovered) {
+
+ double avg_weight = sum / active;
+
+ for (i = n - afl->queued_discovered; i < n; i++) {
+
+ struct queue_entry *q = afl->queue_buf[i];
+
+ if (likely(!q->disabled) && q->weight > avg_weight) {
+
+ double prev_weight = q->weight;
+ q->weight *= (2.0 * (i / n));
+ sum += (q->weight - prev_weight);
+
+ }
+
+ }
+
+ }
+
for (i = 0; i < n; i++) {
// weight is always 0 for disabled entries