afl: add define to disable rand_r use

The randomness affects AFL. It creates variable test cases, which
we need to avoid.
pull/2002/merge
Victor Julien 9 years ago
parent 4c1c13d110
commit b2695600ba

@ -132,10 +132,11 @@ void DefragInitConfig(char quiet)
SC_ATOMIC_INIT(defragtracker_prune_idx);
DefragTrackerQueueInit(&defragtracker_spare_q);
#ifndef AFLFUZZ_NO_RANDOM
unsigned int seed = RandomTimePreseed();
/* set defaults */
defrag_config.hash_rand = (int)(DEFRAG_DEFAULT_HASHSIZE * (rand_r(&seed) / RAND_MAX + 1.0));
#endif
defrag_config.hash_size = DEFRAG_DEFAULT_HASHSIZE;
defrag_config.memcap = DEFRAG_DEFAULT_MEMCAP;
defrag_config.prealloc = DEFRAG_DEFAULT_PREALLOC;

@ -355,10 +355,11 @@ void FlowInitConfig(char quiet)
FlowQueueInit(&flow_spare_q);
FlowQueueInit(&flow_recycle_q);
#ifndef AFLFUZZ_NO_RANDOM
unsigned int seed = RandomTimePreseed();
/* set defaults */
flow_config.hash_rand = (int)( FLOW_DEFAULT_HASHSIZE * (rand_r(&seed) / RAND_MAX + 1.0));
#endif
flow_config.hash_size = FLOW_DEFAULT_HASHSIZE;
flow_config.memcap = FLOW_DEFAULT_MEMCAP;
flow_config.prealloc = FLOW_DEFAULT_PREALLOC;

@ -141,10 +141,11 @@ void HostInitConfig(char quiet)
SC_ATOMIC_INIT(host_prune_idx);
HostQueueInit(&host_spare_q);
#ifndef AFLFUZZ_NO_RANDOM
unsigned int seed = RandomTimePreseed();
/* set defaults */
host_config.hash_rand = (int)( HOST_DEFAULT_HASHSIZE * (rand_r(&seed) / RAND_MAX + 1.0));
#endif
host_config.hash_size = HOST_DEFAULT_HASHSIZE;
host_config.memcap = HOST_DEFAULT_MEMCAP;
host_config.prealloc = HOST_DEFAULT_PREALLOC;

@ -137,10 +137,11 @@ void IPPairInitConfig(char quiet)
SC_ATOMIC_INIT(ippair_prune_idx);
IPPairQueueInit(&ippair_spare_q);
#ifndef AFLFUZZ_NO_RANDOM
unsigned int seed = RandomTimePreseed();
/* set defaults */
ippair_config.hash_rand = (int)( IPPAIR_DEFAULT_HASHSIZE * (rand_r(&seed) / RAND_MAX + 1.0));
#endif
ippair_config.hash_size = IPPAIR_DEFAULT_HASHSIZE;
ippair_config.memcap = IPPAIR_DEFAULT_MEMCAP;
ippair_config.prealloc = IPPAIR_DEFAULT_PREALLOC;

@ -228,6 +228,8 @@
#endif
#endif
#define AFLFUZZ_NO_RANDOM 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 */
#define xstr(s) str(s)

Loading…
Cancel
Save