aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/afl-forkserver.c2
-rw-r--r--src/afl-fuzz.c13
2 files changed, 12 insertions, 3 deletions
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index 508b5fa7..1381236c 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -1931,7 +1931,7 @@ afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
if (exec_ms > timeout) {
- /* If there was no response from forkserver after timeout seconds,
+ /* If there was no response from forkserver after timeout milliseconds,
we kill the child. The forkserver should inform us afterwards */
s32 tmp_pid = fsrv->child_pid;
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 9c89b2a1..08f716fa 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -2493,8 +2493,17 @@ int main(int argc, char **argv_orig, char **envp) {
for (entry = 0; entry < afl->queued_items; ++entry)
if (!afl->queue_buf[entry]->disabled)
- if (afl->queue_buf[entry]->exec_us > max_ms)
- max_ms = afl->queue_buf[entry]->exec_us;
+ if ((afl->queue_buf[entry]->exec_us/1000) > max_ms)
+ max_ms = afl->queue_buf[entry]->exec_us/1000;
+
+ // Add 20% as a safety margin, capped to exec_tmout given in -t option
+ max_ms *= 1.2;
+ if(max_ms > afl->fsrv.exec_tmout)
+ max_ms = afl->fsrv.exec_tmout;
+
+ // Ensure that there is a sensible timeout even for very fast binaries
+ if(max_ms < 5)
+ max_ms = 5;
afl->fsrv.exec_tmout = max_ms;
afl->timeout_given = 1;