diff options
author | Robert Swiecki <robert@swiecki.net> | 2019-04-17 22:02:53 +0200 |
---|---|---|
committer | Robert Swiecki <robert@swiecki.net> | 2019-04-17 22:02:53 +0200 |
commit | af7a92b9a644d1cc75b415351d9cb2a52eadefcf (patch) | |
tree | fe5854729e0a4524df7242d2a94106ff91f863f6 | |
parent | 251ee7cf631b31ef92b2426f84e6a44da1748fc8 (diff) | |
download | honggfuzz-af7a92b9a644d1cc75b415351d9cb2a52eadefcf.tar.gz |
subproc: use TEMP_FAILURE_RETRY with some restartable funcs
-rw-r--r-- | input.c | 4 | ||||
-rw-r--r-- | report.c | 4 | ||||
-rw-r--r-- | subproc.c | 13 |
3 files changed, 13 insertions, 8 deletions
@@ -183,7 +183,7 @@ bool input_init(honggfuzz_t* hfuzz) { return false; } - int dir_fd = open(hfuzz->io.inputDir, O_DIRECTORY | O_RDONLY | O_CLOEXEC); + int dir_fd = TEMP_FAILURE_RETRY(open(hfuzz->io.inputDir, O_DIRECTORY | O_RDONLY | O_CLOEXEC)); if (dir_fd == -1) { PLOG_W("open('%s', O_DIRECTORY|O_RDONLY|O_CLOEXEC)", hfuzz->io.inputDir); return false; @@ -452,4 +452,4 @@ bool input_feedbackMutateFile(run_t* run) { input_setSize(run, (size_t)sz); return true; -}
\ No newline at end of file +} @@ -23,6 +23,7 @@ #include "report.h" +#include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <stdio.h> @@ -79,7 +80,8 @@ void report_Report(run_t* run) { snprintf(reportFName, sizeof(reportFName), "%s", run->global->cfg.reportFile); } - reportFD = open(reportFName, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644); + reportFD = + TEMP_FAILURE_RETRY(open(reportFName, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, 0644)); if (reportFD == -1) { PLOG_F("Couldn't open('%s') for writing", reportFName); } @@ -251,20 +251,22 @@ static bool subproc_PrepareExecv(run_t* run) { /* close_stderr= */ run->global->exe.nullifyStdio); /* The bitmap structure */ - if (run->global->feedback.bbFd != -1 && dup2(run->global->feedback.bbFd, _HF_BITMAP_FD) == -1) { + if (run->global->feedback.bbFd != -1 && + TEMP_FAILURE_RETRY(dup2(run->global->feedback.bbFd, _HF_BITMAP_FD)) == -1) { PLOG_E("dup2(%d, _HF_BITMAP_FD=%d)", run->global->feedback.bbFd, _HF_BITMAP_FD); return false; } /* The input file to _HF_INPUT_FD */ - if (run->global->exe.persistent && dup2(run->dynamicFileFd, _HF_INPUT_FD) == -1) { + if (run->global->exe.persistent && + TEMP_FAILURE_RETRY(dup2(run->dynamicFileFd, _HF_INPUT_FD)) == -1) { PLOG_E("dup2('%d', _HF_INPUT_FD='%d')", run->dynamicFileFd, _HF_INPUT_FD); return false; } /* The log FD */ if ((run->global->exe.netDriver || run->global->exe.persistent)) { - if (dup2(logFd(), _HF_LOG_FD) == -1) { + if (TEMP_FAILURE_RETRY(dup2(logFd(), _HF_LOG_FD)) == -1) { PLOG_E("dup2(%d, _HF_LOG_FD=%d)", logFd(), _HF_LOG_FD); return false; } @@ -285,7 +287,8 @@ static bool subproc_PrepareExecv(run_t* run) { LOG_E("Couldn't save data to a temporary file"); return false; } - if (run->global->exe.fuzzStdin && dup2(run->dynamicFileCopyFd, STDIN_FILENO) == -1) { + if (run->global->exe.fuzzStdin && + TEMP_FAILURE_RETRY(dup2(run->dynamicFileCopyFd, STDIN_FILENO)) == -1) { PLOG_E("dup2(_HF_INPUT_FD=%d, STDIN_FILENO=%d)", run->dynamicFileCopyFd, STDIN_FILENO); return false; } @@ -341,7 +344,7 @@ static bool subproc_New(run_t* run) { signal(SIGALRM, SIG_DFL); if (run->global->exe.persistent) { - if (dup2(sv[1], _HF_PERSISTENT_FD) == -1) { + if (TEMP_FAILURE_RETRY(dup2(sv[1], _HF_PERSISTENT_FD)) == -1) { PLOG_F("dup2('%d', '%d')", sv[1], _HF_PERSISTENT_FD); } close(sv[0]); |