From a42251d459833c061358687cc16da34d53045feb Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 5 Dec 2015 14:29:14 +0100 Subject: [PATCH] afl: add define to disable mgt threads The inherent non-deterministic nature of the management threads creates variable test cases. --- src/counters.c | 4 ++++ src/flow-manager.c | 12 ++++++++++++ src/suricata-common.h | 1 + 3 files changed, 17 insertions(+) diff --git a/src/counters.c b/src/counters.c index add05fca79..5e6d558c46 100644 --- a/src/counters.c +++ b/src/counters.c @@ -221,6 +221,10 @@ static ConfNode *GetConfig(void) { static void StatsInitCtx(void) { SCEnter(); +#ifdef AFLFUZZ_DISABLE_MGTTHREADS + stats_enabled = FALSE; + SCReturn; +#endif ConfNode *stats = GetConfig(); if (stats != NULL) { const char *enabled = ConfNodeLookupChildValue(stats, "enabled"); diff --git a/src/flow-manager.c b/src/flow-manager.c index 4cd53aacd5..9b9920eb4d 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -105,6 +105,9 @@ typedef struct FlowTimeoutCounters_ { */ void FlowDisableFlowManagerThread(void) { +#ifdef AFLFUZZ_DISABLE_MGTTHREADS + return; +#endif ThreadVars *tv = NULL; int cnt = 0; @@ -708,6 +711,9 @@ static uint64_t FlowGetMemuse(void) /** \brief spawn the flow manager thread */ void FlowManagerThreadSpawn() { +#ifdef AFLFUZZ_DISABLE_MGTTHREADS + return; +#endif intmax_t setting = 1; (void)ConfGetInt("flow.managers", &setting); @@ -868,6 +874,9 @@ int FlowRecyclerReadyToShutdown(void) /** \brief spawn the flow recycler thread */ void FlowRecyclerThreadSpawn() { +#ifdef AFLFUZZ_DISABLE_MGTTHREADS + return; +#endif intmax_t setting = 1; (void)ConfGetInt("flow.recyclers", &setting); @@ -917,6 +926,9 @@ void FlowRecyclerThreadSpawn() */ void FlowDisableFlowRecyclerThread(void) { +#ifdef AFLFUZZ_DISABLE_MGTTHREADS + return; +#endif ThreadVars *tv = NULL; int cnt = 0; diff --git a/src/suricata-common.h b/src/suricata-common.h index 4910c4185d..ff8d514725 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -229,6 +229,7 @@ #endif #define AFLFUZZ_NO_RANDOM 1 +#define AFLFUZZ_DISABLE_MGTTHREADS 1 /* we need this to stringify the defines which are supplied at compiletime see: http://gcc.gnu.org/onlinedocs/gcc-3.4.1/cpp/Stringification.html#Stringification */