hopefully better -z algorithm

This commit is contained in:
vanhauser-thc
2023-04-08 13:00:57 +02:00
parent d67ee17778
commit f9851dbfbb

View File

@ -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