diff options
author | van Hauser <vh@thc.org> | 2020-09-04 22:48:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-04 22:48:46 +0200 |
commit | 4f7a8a4c70de1b93b1dccd8f2bf092ec4b3626dc (patch) | |
tree | 8c81a16ba76661b0df5307b9964275ff529d4deb /src/afl-forkserver.c | |
parent | 7f621509eee57f0b6fd9ad542adc4f2acafeb059 (diff) | |
parent | 976ee9022cda95e0715b82ff866098ad293117c9 (diff) | |
download | afl++-4f7a8a4c70de1b93b1dccd8f2bf092ec4b3626dc.tar.gz |
Merge pull request #542 from AFLplusplus/dev
push to stable
Diffstat (limited to 'src/afl-forkserver.c')
-rw-r--r-- | src/afl-forkserver.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index 93203cb2..58932bc4 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -240,6 +240,23 @@ static void afl_fauxsrv_execv(afl_forkserver_t *fsrv, char **argv) { if (!child_pid) { // New child + close(fsrv->out_dir_fd); + close(fsrv->dev_null_fd); + close(fsrv->dev_urandom_fd); + + if (fsrv->plot_file != NULL) { + + fclose(fsrv->plot_file); + fsrv->plot_file = NULL; + + } + + // enable terminating on sigpipe in the childs + struct sigaction sa; + memset((char *)&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + sigaction(SIGPIPE, &sa, NULL); + signal(SIGCHLD, old_sigchld_handler); // FORKSRV_FD is for communication with AFL, we don't need it in the // child. @@ -361,11 +378,16 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* CHILD PROCESS */ + // enable terminating on sigpipe in the childs + struct sigaction sa; + memset((char *)&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_DFL; + sigaction(SIGPIPE, &sa, NULL); + struct rlimit r; /* Umpf. On OpenBSD, the default fd limit for root users is set to soft 128. Let's try to fix that... */ - if (!getrlimit(RLIMIT_NOFILE, &r) && r.rlim_cur < FORKSRV_FD + 2) { r.rlim_cur = FORKSRV_FD + 2; @@ -432,7 +454,12 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, close(fsrv->dev_null_fd); close(fsrv->dev_urandom_fd); - if (fsrv->plot_file != NULL) { fclose(fsrv->plot_file); } + if (fsrv->plot_file != NULL) { + + fclose(fsrv->plot_file); + fsrv->plot_file = NULL; + + } /* This should improve performance a bit, since it stops the linker from doing extra work post-fork(). */ |