aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/afl-common.c8
-rw-r--r--src/afl-forkserver.c5
-rw-r--r--src/afl-fuzz-cmplog.c6
-rw-r--r--src/afl-fuzz-init.c6
-rw-r--r--src/afl-fuzz-run.c6
-rw-r--r--src/afl-fuzz-stats.c14
-rw-r--r--src/afl-showmap.c2
-rw-r--r--src/afl-tmin.c2
8 files changed, 27 insertions, 22 deletions
diff --git a/src/afl-common.c b/src/afl-common.c
index 7eee5265..12b0355e 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -40,6 +40,7 @@
u8 be_quiet = 0;
u8 *doc_path = "";
+u8 last_intr = 0;
char *afl_environment_variables[] = {
@@ -754,7 +755,8 @@ u8 *u_stringify_time_diff(u8 *buf, u64 cur_ms, u64 event_ms) {
Returns the time passed to read.
If the wait times out, returns timeout_ms + 1;
Returns 0 if an error occurred (fd closed, signal, ...); */
-u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms) {
+u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms,
+ volatile u8 *stop_soon_p) {
struct timeval timeout;
fd_set readfds;
@@ -779,8 +781,8 @@ u32 read_timed(s32 fd, void *buf, size_t len, u32 timeout_ms) {
} else if (sret < 0) {
- // perror("sret malloc");
- // TODO: catch other (errno == EINTR) than ctrl+c?
+ /* Retry select for all signals other than than ctrl+c */
+ if (errno == EINTR && !*stop_soon_p) { continue; }
return 0;
}
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index b3b86685..56c3c9d5 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -160,7 +160,8 @@ static void afl_fauxsrv_execv(afl_forkserver_t *fsrv, char **argv) {
cloning a stopped child. So, we just execute once, and then send commands
through a pipe. The other part of this logic is in afl-as.h / llvm_mode */
-void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv) {
+void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
+ volatile u8 *stop_soon_p) {
int st_pipe[2], ctl_pipe[2];
int status;
@@ -317,7 +318,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv) {
rlen = 4;
u32 time = read_timed(fsrv->fsrv_st_fd, &status, rlen,
- fsrv->exec_tmout * FORK_WAIT_MULT);
+ fsrv->exec_tmout * FORK_WAIT_MULT, stop_soon_p);
if (time > fsrv->exec_tmout * FORK_WAIT_MULT) {
diff --git a/src/afl-fuzz-cmplog.c b/src/afl-fuzz-cmplog.c
index 98f7db05..5ad73539 100644
--- a/src/afl-fuzz-cmplog.c
+++ b/src/afl-fuzz-cmplog.c
@@ -187,7 +187,8 @@ void init_cmplog_forkserver(afl_state_t *afl) {
rlen = 4;
u32 timeout_ms = afl->fsrv.exec_tmout * FORK_WAIT_MULT;
/* Reuse readfds as exceptfds to see when the child closed the pipe */
- u32 exec_ms = read_timed(afl->cmplog_fsrv_st_fd, &status, rlen, timeout_ms);
+ u32 exec_ms = read_timed(afl->cmplog_fsrv_st_fd, &status, rlen, timeout_ms,
+ &afl->stop_soon);
if (!exec_ms) {
@@ -416,7 +417,8 @@ u8 run_cmplog_target(afl_state_t *afl, u32 timeout) {
/* Configure timeout, as requested by user, then wait for child to terminate.
*/
- exec_ms = read_timed(afl->cmplog_fsrv_st_fd, &status, 4, timeout);
+ exec_ms =
+ read_timed(afl->cmplog_fsrv_st_fd, &status, 4, timeout, &afl->stop_soon);
if (exec_ms > timeout) {
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index ce30e599..6e0485e5 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -134,14 +134,12 @@ void bind_to_free_cpu(afl_state_t *afl) {
for (i = 0; i < proccount; i++) {
#if defined(__FreeBSD__)
- if (!strcmp(procs[i].ki_comm, "idle"))
- continue;
+ if (!strcmp(procs[i].ki_comm, "idle")) continue;
// fix when ki_oncpu = -1
int oncpu;
oncpu = procs[i].ki_oncpu;
- if (oncpu == -1)
- oncpu = procs[i].ki_lastcpu;
+ if (oncpu == -1) oncpu = procs[i].ki_lastcpu;
if (oncpu != -1 && oncpu < sizeof(cpu_used) && procs[i].ki_pctcpu > 60)
cpu_used[oncpu] = 1;
diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c
index 47f6e9d9..9bbdd23a 100644
--- a/src/afl-fuzz-run.c
+++ b/src/afl-fuzz-run.c
@@ -67,7 +67,8 @@ u8 run_target(afl_state_t *afl, u32 timeout) {
if (afl->fsrv.child_pid <= 0) FATAL("Fork server is misbehaving (OOM?)");
- exec_ms = read_timed(afl->fsrv.fsrv_st_fd, &status, 4, timeout);
+ exec_ms =
+ read_timed(afl->fsrv.fsrv_st_fd, &status, 4, timeout, &afl->stop_soon);
if (exec_ms > timeout) {
@@ -308,7 +309,8 @@ u8 calibrate_case(afl_state_t *afl, struct queue_entry *q, u8 *use_mem,
/* Make sure the forkserver is up before we do anything, and let's not
count its spin-up time toward binary calibration. */
- if (!afl->fsrv.fsrv_pid) afl_fsrv_start(&afl->fsrv, afl->argv);
+ if (!afl->fsrv.fsrv_pid)
+ afl_fsrv_start(&afl->fsrv, afl->argv, &afl->stop_soon);
if (afl->dumb_mode != 1 && !afl->no_forkserver && !afl->cmplog_fsrv_pid &&
afl->shm.cmplog_mode)
init_cmplog_forkserver(afl);
diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c
index 850555b5..ab84bf3f 100644
--- a/src/afl-fuzz-stats.c
+++ b/src/afl-fuzz-stats.c
@@ -366,9 +366,9 @@ void show_stats(afl_state_t *afl) {
/* Lord, forgive me this. */
- SAYF(SET_G1 bSTG bLT bH bSTOP cCYA
+ SAYF(SET_G1 bSTG bLT bH bSTOP cCYA
" process timing " bSTG bH30 bH5 bH bHB bH bSTOP cCYA
- " overall results " bSTG bH2 bH2 bRT "\n");
+ " overall results " bSTG bH2 bH2 bRT "\n");
if (afl->dumb_mode) {
@@ -450,9 +450,9 @@ void show_stats(afl_state_t *afl) {
" uniq hangs : " cRST "%-6s" bSTG bV "\n",
time_tmp, tmp);
- SAYF(bVR bH bSTOP cCYA
+ SAYF(bVR bH bSTOP cCYA
" cycle progress " bSTG bH10 bH5 bH2 bH2 bHB bH bSTOP cCYA
- " map coverage " bSTG bH bHT bH20 bH2 bVL "\n");
+ " map coverage " bSTG bH bHT bH20 bH2 bVL "\n");
/* This gets funny because we want to print several variable-length variables
together, but then cram them into a fixed-width field - so we need to
@@ -481,9 +481,9 @@ void show_stats(afl_state_t *afl) {
SAYF(bSTOP " count coverage : " cRST "%-21s" bSTG bV "\n", tmp);
- SAYF(bVR bH bSTOP cCYA
+ SAYF(bVR bH bSTOP cCYA
" stage progress " bSTG bH10 bH5 bH2 bH2 bX bH bSTOP cCYA
- " findings in depth " bSTG bH10 bH5 bH2 bH2 bVL "\n");
+ " findings in depth " bSTG bH10 bH5 bH2 bH2 bVL "\n");
sprintf(tmp, "%s (%0.02f%%)", u_stringify_int(IB(0), afl->queued_favored),
((double)afl->queued_favored) * 100 / afl->queued_paths);
@@ -557,7 +557,7 @@ void show_stats(afl_state_t *afl) {
/* Aaaalmost there... hold on! */
- SAYF(bVR bH cCYA bSTOP
+ SAYF(bVR bH cCYA bSTOP
" fuzzing strategy yields " bSTG bH10 bHT bH10 bH5 bHB bH bSTOP cCYA
" path geometry " bSTG bH5 bH2 bVL "\n");
diff --git a/src/afl-showmap.c b/src/afl-showmap.c
index e4463dc4..2fd17fb1 100644
--- a/src/afl-showmap.c
+++ b/src/afl-showmap.c
@@ -951,7 +951,7 @@ int main(int argc, char **argv_orig, char **envp) {
}
- afl_fsrv_start(fsrv, use_argv);
+ afl_fsrv_start(fsrv, use_argv, &stop_soon);
while (done == 0 && (dir_ent = readdir(dir_in))) {
diff --git a/src/afl-tmin.c b/src/afl-tmin.c
index 30e76d42..f899a6b5 100644
--- a/src/afl-tmin.c
+++ b/src/afl-tmin.c
@@ -1133,7 +1133,7 @@ int main(int argc, char **argv_orig, char **envp) {
read_initial_file();
- afl_fsrv_start(fsrv, use_argv);
+ afl_fsrv_start(fsrv, use_argv, &stop_soon);
ACTF("Performing dry run (mem limit = %llu MB, timeout = %u ms%s)...",
fsrv->mem_limit, fsrv->exec_tmout, edges_only ? ", edges only" : "");