cfg_prec->request.inspect_window = HTP_CONFIG_DEFAULT_REQUEST_INSPECT_WINDOW;
cfg_prec->response.inspect_min_size = HTP_CONFIG_DEFAULT_RESPONSE_INSPECT_MIN_SIZE;
cfg_prec->response.inspect_window = HTP_CONFIG_DEFAULT_RESPONSE_INSPECT_WINDOW;
-#ifndef AFLFUZZ_NO_RANDOM
- cfg_prec->randomize = HTP_CONFIG_DEFAULT_RANDOMIZE;
-#else
- cfg_prec->randomize = 0;
-#endif
+
+ if (!g_disable_randomness) {
+ cfg_prec->randomize = HTP_CONFIG_DEFAULT_RANDOMIZE;
+ } else {
+ cfg_prec->randomize = 0;
+ }
cfg_prec->randomize_range = HTP_CONFIG_DEFAULT_RANDOMIZE_RANGE;
htp_config_register_request_header_data(cfg_prec->cfg, HTPCallbackRequestHeaderData);
(size_t)HTP_CONFIG_DEFAULT_FIELD_LIMIT_SOFT,
(size_t)limit);
} else if (strcasecmp("randomize-inspection-sizes", p->name) == 0) {
-#ifndef AFLFUZZ_NO_RANDOM
- cfg_prec->randomize = ConfValIsTrue(p->val);
-#endif
+ if (!g_disable_randomness) {
+ cfg_prec->randomize = ConfValIsTrue(p->val);
+ }
} else if (strcasecmp("randomize-inspection-range", p->name) == 0) {
uint32_t range = atoi(p->val);
if (range > 100) {
SC_ATOMIC_INIT(defragtracker_prune_idx);
DefragTrackerQueueInit(&defragtracker_spare_q);
-#ifndef AFLFUZZ_NO_RANDOM
/* set defaults */
defrag_config.hash_rand = (uint32_t)RandomGet();
-#endif
defrag_config.hash_size = DEFRAG_DEFAULT_HASHSIZE;
defrag_config.memcap = DEFRAG_DEFAULT_MEMCAP;
defrag_config.prealloc = DEFRAG_DEFAULT_PREALLOC;
FlowQueueInit(&flow_spare_q);
FlowQueueInit(&flow_recycle_q);
-#ifndef AFLFUZZ_NO_RANDOM
/* set defaults */
flow_config.hash_rand = (uint32_t)RandomGet();
-#endif
flow_config.hash_size = FLOW_DEFAULT_HASHSIZE;
flow_config.memcap = FLOW_DEFAULT_MEMCAP;
flow_config.prealloc = FLOW_DEFAULT_PREALLOC;
SC_ATOMIC_INIT(host_prune_idx);
HostQueueInit(&host_spare_q);
-#ifndef AFLFUZZ_NO_RANDOM
/* set defaults */
host_config.hash_rand = (uint32_t)RandomGet();
-#endif
host_config.hash_size = HOST_DEFAULT_HASHSIZE;
host_config.memcap = HOST_DEFAULT_MEMCAP;
host_config.prealloc = HOST_DEFAULT_PREALLOC;
SC_ATOMIC_INIT(ippair_prune_idx);
IPPairQueueInit(&ippair_spare_q);
-#ifndef AFLFUZZ_NO_RANDOM
/* set defaults */
ippair_config.hash_rand = (uint32_t)RandomGet();
-#endif
ippair_config.hash_size = IPPAIR_DEFAULT_HASHSIZE;
ippair_config.memcap = IPPAIR_DEFAULT_MEMCAP;
ippair_config.prealloc = IPPAIR_DEFAULT_PREALLOC;
/** highest mtu of the interfaces we monitor */
int g_default_mtu = 0;
+/** disable randomness to get reproducible results accross runs */
+#ifndef AFLFUZZ_NO_RANDOM
+int g_disable_randomness = 0;
+#else
+int g_disable_randomness = 1;
+#endif
+
int EngineModeIsIPS(void)
{
return (g_engine_mode == ENGINE_MODE_IPS);
{"netmap", optional_argument, 0, 0},
{"pcap", optional_argument, 0, 0},
{"simulate-ips", 0, 0 , 0},
+ {"no-random", 0, &g_disable_randomness, 1},
/* AFL app-layer options. */
{"afl-http-request", required_argument, 0 , 0},
void GlobalsInitPreConfig();
extern volatile uint8_t suricata_ctl_flags;
+extern int g_disable_randomness;
/* uppercase to lowercase conversion lookup table */
uint8_t g_u8_lowercasetable[256];
long int RandomGet(void)
{
+ if (g_disable_randomness)
+ return 0;
+
HCRYPTPROV p;
if (!(CryptAcquireContext(&p, NULL, NULL,
PROV_RSA_FULL, 0))) {
#elif defined(HAVE_CLOCK_GETTIME)
long int RandomGet(void)
{
+ if (g_disable_randomness)
+ return 0;
+
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
#else
long int RandomGet(void)
{
+ if (g_disable_randomness)
+ return 0;
+
struct timeval tv;
memset(&tv, 0, sizeof(tv));
gettimeofday(&tv, NULL);