fix cmplog screen update crash
MODIFY
docs/Changelog.md
docs/Changelog.md
@@ -9,9 +9,9 @@ Want to stay in the loop on major new features? Join our mailing list by
sending a mail to <afl-users+subscribe@googlegroups.com>.
### Version ++3.14a (release)
- - Fix for llvm 13
- afl-fuzz:
- fix -F when a '/' was part of the parameter
+ - fixed a crash for cmplog for very slow inputs
- removed implied -D determinstic from -M main
- if the target becomes unavailable check out out/default/error.txt for
an indicator why
@@ -21,6 +21,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
- We do support llvm versions from 3.8 again
- afl_analyze
- fix timeout handling and support forkserver
+ - Fix for llvm 13
- ensure afl-compiler-rt is built for gcc_module
- afl-analyze now uses the forkserver for increased performance

MODIFY
src/afl-common.c
src/afl-common.c
@@ -751,6 +751,8 @@ void read_bitmap(u8 *fname, u8 *map, size_t len) {
}
+/* Get unix time in milliseconds */
+
u64 get_cur_time(void) {
struct timeval tv;

MODIFY
src/afl-fuzz-redqueen.c
src/afl-fuzz-redqueen.c
@@ -252,7 +252,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len,
u64 start_time = get_cur_time();
#endif
- u32 screen_update = 1000000 / afl->queue_cur->exec_us;
+ u32 screen_update;
u64 orig_hit_cnt, new_hit_cnt, exec_cksum;
orig_hit_cnt = afl->queued_paths + afl->unique_crashes;
@@ -261,6 +261,24 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len,
afl->stage_max = (len << 1);
afl->stage_cur = 0;
+ if (likely(afl->queue_cur->exec_us)) {
+
+ if (likely((100000 / 2) >= afl->queue_cur->exec_us)) {
+
+ screen_update = 100000 / afl->queue_cur->exec_us;
+
+ } else {
+
+ screen_update = 1;
+
+ }
+
+ } else {
+
+ screen_update = 100000;
+
+ }
+
// in colorization we do not classify counts, hence we have to calculate
// the original checksum.
if (unlikely(get_exec_checksum(afl, buf, len, &exec_cksum))) {
@@ -905,8 +923,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h,
// test for arithmetic, eg. "if ((user_val - 0x1111) == 0x1234) ..."
s64 diff = pattern - b_val;
s64 o_diff = o_pattern - o_b_val;
- /*
- fprintf(stderr, "DIFF1 idx=%03u shape=%02u %llx-%llx=%lx\n", idx,
+ /* fprintf(stderr, "DIFF1 idx=%03u shape=%02u %llx-%llx=%lx\n", idx,
h->shape + 1, o_pattern, o_b_val, o_diff);
fprintf(stderr, "DIFF1 %016llx %llx-%llx=%lx\n", repl, pattern,
b_val, diff); */
@@ -936,8 +953,10 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h,
s64 o_diff = o_pattern ^ o_b_val;
/* fprintf(stderr, "DIFF2 idx=%03u shape=%02u %llx-%llx=%lx\n",
- idx, h->shape + 1, o_pattern, o_b_val, o_diff); fprintf(stderr,
- "DIFF2 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);*/
+ idx, h->shape + 1, o_pattern, o_b_val, o_diff);
+ fprintf(stderr,
+ "DIFF2 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);
+ */
if (diff == o_diff && diff) {
// this could be a XOR transformation
@@ -983,8 +1002,10 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h,
}
/* fprintf(stderr, "DIFF3 idx=%03u shape=%02u %llx-%llx=%lx\n",
- idx, h->shape + 1, o_pattern, o_b_val, o_diff); fprintf(stderr,
- "DIFF3 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);*/
+ idx, h->shape + 1, o_pattern, o_b_val, o_diff);
+ fprintf(stderr,
+ "DIFF3 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);
+ */
if (o_diff && diff) {
// this could be a lower to upper
@@ -1030,8 +1051,10 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h,
}
/* fprintf(stderr, "DIFF4 idx=%03u shape=%02u %llx-%llx=%lx\n",
- idx, h->shape + 1, o_pattern, o_b_val, o_diff); fprintf(stderr,
- "DIFF4 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);*/
+ idx, h->shape + 1, o_pattern, o_b_val, o_diff);
+ fprintf(stderr,
+ "DIFF4 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);
+ */
if (o_diff && diff) {
// this could be a lower to upper
@@ -1383,7 +1406,8 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h,
}
- //#endif /* CMPLOG_SOLVE_ARITHMETIC
+ //#endif /*
+ // CMPLOG_SOLVE_ARITHMETIC
return 0;
@@ -2152,7 +2176,8 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl,
memcpy(buf + idx, tmp, i + 1);
if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; }
- // fprintf(stderr, "RTN ATTEMPT tohex %u result %u\n", tohex, *status);
+ // fprintf(stderr, "RTN ATTEMPT tohex %u result %u\n", tohex,
+ // *status);
}
@@ -2235,7 +2260,8 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl,
for (j = 0; j <= i; j++)
buf[idx + j] = repl[j] - arith_val[j];
if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; }
- // fprintf(stderr, "RTN ATTEMPT arith %u result %u\n", arith, *status);
+ // fprintf(stderr, "RTN ATTEMPT arith %u result %u\n", arith,
+ // *status);
}
@@ -2328,15 +2354,16 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf,
/*
struct cmp_header *hh = &afl->orig_cmp_map->headers[key];
- fprintf(stderr, "RTN N hits=%u id=%u shape=%u attr=%u v0=", h->hits, h->id,
- h->shape, h->attribute); for (j = 0; j < 8; j++) fprintf(stderr, "%02x",
- o->v0[j]); fprintf(stderr, " v1="); for (j = 0; j < 8; j++) fprintf(stderr,
- "%02x", o->v1[j]); fprintf(stderr, "\nRTN O hits=%u id=%u shape=%u attr=%u
- o0=", hh->hits, hh->id, hh->shape, hh->attribute); for (j = 0; j < 8; j++)
- fprintf(stderr, "%02x", orig_o->v0[j]);
+ fprintf(stderr, "RTN N hits=%u id=%u shape=%u attr=%u v0=", h->hits,
+ h->id, h->shape, h->attribute);
+ for (j = 0; j < 8; j++) fprintf(stderr, "%02x", o->v0[j]);
+ fprintf(stderr, " v1=");
+ for (j = 0; j < 8; j++) fprintf(stderr, "%02x", o->v1[j]);
+ fprintf(stderr, "\nRTN O hits=%u id=%u shape=%u attr=%u o0=",
+ hh->hits, hh->id, hh->shape, hh->attribute);
+ for (j = 0; j < 8; j++) fprintf(stderr, "%02x", orig_o->v0[j]);
fprintf(stderr, " o1=");
- for (j = 0; j < 8; j++)
- fprintf(stderr, "%02x", orig_o->v1[j]);
+ for (j = 0; j < 8; j++) fprintf(stderr, "%02x", orig_o->v1[j]);
fprintf(stderr, "\n");
*/

fix cmplog screen update crash