qa: add --no-random commandline option

pull/2666/head
Victor Julien 8 years ago
parent ba61265403
commit c3b4dd5a7d

@ -2149,11 +2149,12 @@ static void HTPConfigSetDefaultsPhase1(HTPCfgRec *cfg_prec)
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);
@ -2471,9 +2472,9 @@ static void HTPConfigParseParameters(HTPCfgRec *cfg_prec, ConfNode *s,
(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) {

@ -133,10 +133,8 @@ void DefragInitConfig(char quiet)
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;

@ -349,10 +349,8 @@ void FlowInitConfig(char quiet)
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;

@ -141,10 +141,8 @@ void HostInitConfig(char quiet)
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;

@ -137,10 +137,8 @@ void IPPairInitConfig(char quiet)
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;

@ -220,6 +220,13 @@ int sc_set_caps = FALSE;
/** 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);
@ -1461,6 +1468,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
{"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},

@ -172,6 +172,7 @@ typedef struct SCInstance_ {
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];

@ -31,6 +31,9 @@
long int RandomGet(void)
{
if (g_disable_randomness)
return 0;
HCRYPTPROV p;
if (!(CryptAcquireContext(&p, NULL, NULL,
PROV_RSA_FULL, 0))) {
@ -50,6 +53,9 @@ long int RandomGet(void)
#elif defined(HAVE_CLOCK_GETTIME)
long int RandomGet(void)
{
if (g_disable_randomness)
return 0;
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
@ -60,6 +66,9 @@ long int RandomGet(void)
#else
long int RandomGet(void)
{
if (g_disable_randomness)
return 0;
struct timeval tv;
memset(&tv, 0, sizeof(tv));
gettimeofday(&tv, NULL);

Loading…
Cancel
Save