honggfuzz.c (honggfuzz-2.4) | : | honggfuzz.c (honggfuzz-2.5) | ||
---|---|---|---|---|
skipping to change at line 104 | skipping to change at line 104 | |||
PLOG_W("getrlimit(RLIMIT_NOFILE)"); | PLOG_W("getrlimit(RLIMIT_NOFILE)"); | |||
return; | return; | |||
} | } | |||
if (rlim.rlim_cur >= 1024) { | if (rlim.rlim_cur >= 1024) { | |||
return; | return; | |||
} | } | |||
if (rlim.rlim_max < 1024) { | if (rlim.rlim_max < 1024) { | |||
LOG_E("RLIMIT_NOFILE max limit < 1024 (%zu). Expect troubles!", (size_t) rlim.rlim_max); | LOG_E("RLIMIT_NOFILE max limit < 1024 (%zu). Expect troubles!", (size_t) rlim.rlim_max); | |||
return; | return; | |||
} | } | |||
rlim.rlim_cur = MIN(1024, rlim.rlim_max); // we don't need more | rlim.rlim_cur = HF_MIN(1024, rlim.rlim_max); // we don't need more | |||
if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { | if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) { | |||
PLOG_E("Couldn't setrlimit(RLIMIT_NOFILE, cur=%zu/max=%zu)", (size_t)rli m.rlim_cur, | PLOG_E("Couldn't setrlimit(RLIMIT_NOFILE, cur=%zu/max=%zu)", (size_t)rli m.rlim_cur, | |||
(size_t)rlim.rlim_max); | (size_t)rlim.rlim_max); | |||
} | } | |||
} | } | |||
static void setupMainThreadTimer(void) { | static void setupMainThreadTimer(void) { | |||
const struct itimerval it = { | const struct itimerval it = { | |||
.it_value = | .it_value = | |||
{ | { | |||
skipping to change at line 163 | skipping to change at line 163 | |||
if (sigaction(SIGTERM, &sa, NULL) == -1) { | if (sigaction(SIGTERM, &sa, NULL) == -1) { | |||
PLOG_F("sigaction(SIGTERM) failed"); | PLOG_F("sigaction(SIGTERM) failed"); | |||
} | } | |||
if (sigaction(SIGINT, &sa, NULL) == -1) { | if (sigaction(SIGINT, &sa, NULL) == -1) { | |||
PLOG_F("sigaction(SIGINT) failed"); | PLOG_F("sigaction(SIGINT) failed"); | |||
} | } | |||
if (sigaction(SIGQUIT, &sa, NULL) == -1) { | if (sigaction(SIGQUIT, &sa, NULL) == -1) { | |||
PLOG_F("sigaction(SIGQUIT) failed"); | PLOG_F("sigaction(SIGQUIT) failed"); | |||
} | } | |||
if (sigaction(SIGALRM, &sa, NULL) == -1) { | if (sigaction(SIGALRM, &sa, NULL) == -1) { | |||
PLOG_F("sigaction(SIGQUIT) failed"); | PLOG_F("sigaction(SIGALRM) failed"); | |||
} | } | |||
if (sigaction(SIGCHLD, &sa, NULL) == -1) { | if (sigaction(SIGCHLD, &sa, NULL) == -1) { | |||
PLOG_F("sigaction(SIGCHLD) failed"); | PLOG_F("sigaction(SIGCHLD) failed"); | |||
} | } | |||
if (sigaction(SIGWINCH, &sa, NULL) == -1) { | if (sigaction(SIGWINCH, &sa, NULL) == -1) { | |||
PLOG_F("sigaction(SIGWINCH) failed"); | PLOG_F("sigaction(SIGWINCH) failed"); | |||
} | } | |||
} | } | |||
static void setupSignalsMainThread(void) { | static void setupSignalsMainThread(void) { | |||
skipping to change at line 258 | skipping to change at line 258 | |||
break; | break; | |||
} | } | |||
if (sig == SIGCHLD) { | if (sig == SIGCHLD) { | |||
pingThreads(hfuzz); | pingThreads(hfuzz); | |||
} | } | |||
} | } | |||
return NULL; | return NULL; | |||
} | } | |||
static void mainThreadLoop(honggfuzz_t* hfuzz) { | static uint8_t mainThreadLoop(honggfuzz_t* hfuzz) { | |||
setupSignalsMainThread(); | setupSignalsMainThread(); | |||
setupMainThreadTimer(); | setupMainThreadTimer(); | |||
for (;;) { | for (;;) { | |||
if (hfuzz->display.useScreen) { | if (hfuzz->display.useScreen) { | |||
if (ATOMIC_XCHG(clearWin, false)) { | if (ATOMIC_XCHG(clearWin, false)) { | |||
display_clear(); | display_clear(); | |||
} | } | |||
display_display(hfuzz); | display_display(hfuzz); | |||
} | } | |||
skipping to change at line 294 | skipping to change at line 294 | |||
fuzz_setTerminating(); | fuzz_setTerminating(); | |||
for (;;) { | for (;;) { | |||
if (ATOMIC_GET(hfuzz->threads.threadsFinished) >= hfuzz->threads.threads Max) { | if (ATOMIC_GET(hfuzz->threads.threadsFinished) >= hfuzz->threads.threads Max) { | |||
break; | break; | |||
} | } | |||
pingThreads(hfuzz); | pingThreads(hfuzz); | |||
util_sleepForMSec(50); /* 50ms */ | util_sleepForMSec(50); /* 50ms */ | |||
} | } | |||
if (hfuzz->cfg.exitUponCrash && ATOMIC_GET(hfuzz->cnts.crashesCnt) > 0) { | ||||
return hfuzz->cfg.exitCodeUponCrash; | ||||
} else { | ||||
return EXIT_SUCCESS; | ||||
} | ||||
} | } | |||
static const char* strYesNo(bool yes) { | static const char* strYesNo(bool yes) { | |||
return (yes ? "true" : "false"); | return (yes ? "true" : "false"); | |||
} | } | |||
static const char* getGitVersion() { | static const char* getGitVersion() { | |||
static char version[] = "$Id: 2518baeec5b43e203c77a0c69cbac7ef400a4633 $"; | static char version[] = "$Id: 380cf14962c64e3fa902d9442b6c6513869116ed $"; | |||
if (strlen(version) == 47) { | if (strlen(version) == 47) { | |||
version[45] = '\0'; | version[45] = '\0'; | |||
return &version[5]; | return &version[5]; | |||
} | } | |||
return "UNKNOWN"; | return "UNKNOWN"; | |||
} | } | |||
int main(int argc, char** argv) { | int main(int argc, char** argv) { | |||
/* | /* | |||
* Work around CygWin/MinGW | * Work around CygWin/MinGW | |||
skipping to change at line 407 | skipping to change at line 412 | |||
setupRLimits(); | setupRLimits(); | |||
setupSignalsPreThreads(); | setupSignalsPreThreads(); | |||
fuzz_threadsStart(&hfuzz); | fuzz_threadsStart(&hfuzz); | |||
pthread_t sigthread; | pthread_t sigthread; | |||
if (!subproc_runThread(&hfuzz, &sigthread, signalThread, /* joinable= */ fal se)) { | if (!subproc_runThread(&hfuzz, &sigthread, signalThread, /* joinable= */ fal se)) { | |||
LOG_F("Couldn't start the signal thread"); | LOG_F("Couldn't start the signal thread"); | |||
} | } | |||
mainThreadLoop(&hfuzz); | uint8_t exitcode = mainThreadLoop(&hfuzz); | |||
/* Clean-up global buffers */ | /* Clean-up global buffers */ | |||
if (hfuzz.feedback.blocklist) { | if (hfuzz.feedback.blocklist) { | |||
free(hfuzz.feedback.blocklist); | free(hfuzz.feedback.blocklist); | |||
} | } | |||
#if defined(_HF_ARCH_LINUX) | #if defined(_HF_ARCH_LINUX) | |||
if (hfuzz.arch_linux.symsBl) { | if (hfuzz.arch_linux.symsBl) { | |||
free(hfuzz.arch_linux.symsBl); | free(hfuzz.arch_linux.symsBl); | |||
} | } | |||
if (hfuzz.arch_linux.symsWl) { | if (hfuzz.arch_linux.symsWl) { | |||
skipping to change at line 434 | skipping to change at line 439 | |||
if (hfuzz.arch_netbsd.symsWl) { | if (hfuzz.arch_netbsd.symsWl) { | |||
free(hfuzz.arch_netbsd.symsWl); | free(hfuzz.arch_netbsd.symsWl); | |||
} | } | |||
#endif | #endif | |||
if (hfuzz.socketFuzzer.enabled) { | if (hfuzz.socketFuzzer.enabled) { | |||
cleanupSocketFuzzer(); | cleanupSocketFuzzer(); | |||
} | } | |||
printSummary(&hfuzz); | printSummary(&hfuzz); | |||
return EXIT_SUCCESS; | return exitcode; | |||
} | } | |||
End of changes. 7 change blocks. | ||||
6 lines changed or deleted | 11 lines changed or added |