diff options
author | van Hauser <vh@thc.org> | 2020-08-09 00:35:12 +0200 |
---|---|---|
committer | van Hauser <vh@thc.org> | 2020-08-09 00:35:12 +0200 |
commit | e4a0237cbc745552a5b21a2450d7ab55ee98759d (patch) | |
tree | 4a744f0705ab405dd86017b791a510f1dde22a1e /src/afl-fuzz-bitmap.c | |
parent | d8f5502d83ec530bcc1ad15b2d23b2660cd6ce58 (diff) | |
download | afl++-e4a0237cbc745552a5b21a2450d7ab55ee98759d.tar.gz |
step 1
Diffstat (limited to 'src/afl-fuzz-bitmap.c')
-rw-r--r-- | src/afl-fuzz-bitmap.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/afl-fuzz-bitmap.c b/src/afl-fuzz-bitmap.c index aa8d5a18..9cb1b83f 100644 --- a/src/afl-fuzz-bitmap.c +++ b/src/afl-fuzz-bitmap.c @@ -177,6 +177,38 @@ u32 count_bits(afl_state_t *afl, u8 *mem) { } +u32 count_bits_len(afl_state_t *afl, u8 *mem, u32 len) { + + u32 *ptr = (u32 *)mem; + u32 i = (len >> 2); + u32 ret = 0; + + if (len % 4) i++; + + while (i--) { + + u32 v = *(ptr++); + + /* This gets called on the inverse, virgin bitmap; optimize for sparse + data. */ + + if (v == 0xffffffff) { + + ret += 32; + continue; + + } + + v -= ((v >> 1) & 0x55555555); + v = (v & 0x33333333) + ((v >> 2) & 0x33333333); + ret += (((v + (v >> 4)) & 0xF0F0F0F) * 0x01010101) >> 24; + + } + + return ret; + +} + /* Count the number of bytes set in the bitmap. Called fairly sporadically, mostly to update the status screen or calibrate and examine confirmed new paths. */ |