next_p2 replaced by next_pow2

This commit is contained in:
Dominik Maier 2020-04-01 02:03:46 +02:00
parent 25d6d21617
commit d611e7d50e
3 changed files with 7 additions and 18 deletions

View File

@ -184,7 +184,7 @@ void update_bitmap_score(afl_state_t *afl, struct queue_entry *q) {
u32 i;
u64 fav_factor;
u64 fuzz_p2 = next_p2(q->n_fuzz);
u64 fuzz_p2 = next_pow2(q->n_fuzz);
if (afl->schedule == MMOPT || afl->schedule == RARE)
fav_factor = q->len << 2;
@ -201,7 +201,7 @@ void update_bitmap_score(afl_state_t *afl, struct queue_entry *q) {
/* Faster-executing or smaller test cases are favored. */
u64 top_rated_fav_factor;
u64 top_rated_fuzz_p2 = next_p2(afl->top_rated[i]->n_fuzz);
u64 top_rated_fuzz_p2 = next_pow2(afl->top_rated[i]->n_fuzz);
if (afl->schedule == MMOPT || afl->schedule == RARE)
top_rated_fav_factor = afl->top_rated[i]->len << 2;
@ -440,7 +440,7 @@ u32 calculate_score(afl_state_t *afl, struct queue_entry *q) {
if (q->fuzz_level < 16)
factor = ((u32)(1 << q->fuzz_level)) / (fuzz == 0 ? 1 : fuzz);
else
factor = MAX_FACTOR / (fuzz == 0 ? 1 : next_p2(fuzz));
factor = MAX_FACTOR / (fuzz == 0 ? 1 : next_pow2(fuzz));
break;
case LIN: factor = q->fuzz_level / (fuzz == 0 ? 1 : fuzz); break;

View File

@ -608,7 +608,7 @@ u8 trim_case(afl_state_t *afl, struct queue_entry *q, u8 *in_buf) {
/* Select initial chunk len, starting with large steps. */
len_p2 = next_p2(q->len);
len_p2 = next_pow2(q->len);
remove_len = MAX(len_p2 / TRIM_START_STEPS, TRIM_MIN_BYTES);
@ -653,7 +653,7 @@ u8 trim_case(afl_state_t *afl, struct queue_entry *q, u8 *in_buf) {
u32 move_tail = q->len - remove_pos - trim_avail;
q->len -= trim_avail;
len_p2 = next_p2(q->len);
len_p2 = next_pow2(q->len);
memmove(in_buf + remove_pos, in_buf + remove_pos + trim_avail,
move_tail);

View File

@ -404,17 +404,6 @@ static u8 run_target(afl_forkserver_t *fsrv, char **argv, u8 *mem, u32 len,
}
/* Find first power of two greater or equal to val. */
static u32 next_p2(u32 val) {
u32 ret = 1;
while (val > ret)
ret <<= 1;
return ret;
}
/* Actually minimize! */
static void minimize(afl_forkserver_t *fsrv, char **argv) {
@ -432,7 +421,7 @@ static void minimize(afl_forkserver_t *fsrv, char **argv) {
* BLOCK NORMALIZATION *
***********************/
set_len = next_p2(in_len / TMIN_SET_STEPS);
set_len = next_pow2(in_len / TMIN_SET_STEPS);
set_pos = 0;
if (set_len < TMIN_SET_MIN_SIZE) set_len = TMIN_SET_MIN_SIZE;
@ -482,7 +471,7 @@ next_pass:
* BLOCK DELETION *
******************/
del_len = next_p2(in_len / TRIM_START_STEPS);
del_len = next_pow2(in_len / TRIM_START_STEPS);
stage_o_len = in_len;
ACTF(cBRI "Stage #1: " cRST "Removing blocks of data...");