about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-12-17 22:57:28 +0100
committervan Hauser <vh@thc.org>2020-12-17 22:57:28 +0100
commitfd6bff727a860220bdd035952a7666c60f444b3f (patch)
treedada4f1e26de6e2a71dfe237326a896a66abcd7f
parent14c67f15c98b16bb0c22f6a94d66d714bf61af5a (diff)
downloadafl++-fd6bff727a860220bdd035952a7666c60f444b3f.tar.gz
fix crash for very fast targets
-rw-r--r--docs/Changelog.md1
-rw-r--r--src/afl-common.c5
-rw-r--r--src/afl-fuzz-stats.c2
3 files changed, 8 insertions, 0 deletions
diff --git a/docs/Changelog.md b/docs/Changelog.md
index c2ed0a12..ac75c68d 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -10,6 +10,7 @@ sending a mail to <afl-users+subscribe@googlegroups.com>.
 
 
 ### Version ++3.01a (release)
+  - fix crash for very, very fast targets+systems, thanks for reporting @mhlakhani
   - added dummy Makefile to instrumentation/
   - allow instrumenting LLVMFuzzerTestOneInput
 
diff --git a/src/afl-common.c b/src/afl-common.c
index 4df22394..6dc8abe0 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <strings.h>
+#include <math.h>
 
 #include "debug.h"
 #include "alloc-inl.h"
@@ -786,6 +787,10 @@ u8 *u_stringify_float(u8 *buf, double val) {
 
     sprintf(buf, "%0.01f", val);
 
+  } else if (unlikely(isnan(val) || isfinite(val))) {
+
+    strcpy(buf, "999.9");
+
   } else {
 
     return u_stringify_int(buf, (u64)val);
diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c
index 321bbb35..50e2ef15 100644
--- a/src/afl-fuzz-stats.c
+++ b/src/afl-fuzz-stats.c
@@ -371,6 +371,8 @@ void show_stats(afl_state_t *afl) {
 
   if (!afl->stats_last_execs) {
 
+    if (unlikely(cur_ms == afl->start_time)) --afl->start_time;
+
     afl->stats_avg_exec =
         ((double)afl->fsrv.total_execs) * 1000 / (cur_ms - afl->start_time);