diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-15 16:11:53 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-15 16:11:53 +0000 |
commit | 248d1ceb588fd27efe424dbd40fa1a779d6529c2 (patch) | |
tree | 1b09c1d58d1a619e80ad2ffb48b13c8ec60ca3a1 /contrib | |
parent | 27e45bef83fe17b339fe345e3455a67b7416e1d3 (diff) | |
download | rspamd-248d1ceb588fd27efe424dbd40fa1a779d6529c2.tar.gz rspamd-248d1ceb588fd27efe424dbd40fa1a779d6529c2.zip |
Add workaround for bug in valgrind and rdrand
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libottery/ottery_entropy_rdrand.c | 3 | ||||
-rw-r--r-- | contrib/libottery/ottery_global.c | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/contrib/libottery/ottery_entropy_rdrand.c b/contrib/libottery/ottery_entropy_rdrand.c index 62e158c83..c5f12609b 100644 --- a/contrib/libottery/ottery_entropy_rdrand.c +++ b/contrib/libottery/ottery_entropy_rdrand.c @@ -19,6 +19,7 @@ defined(_M_IX86) || \ defined(__INTEL_COMPILER) +extern int ottery_valgrind_; /** Helper: invoke the RDRAND instruction to get 4 random bytes in the output * value. Return 0 on success, and an error on failure. */ static int @@ -39,7 +40,7 @@ ottery_get_entropy_rdrand(const struct ottery_entropy_config *cfg, uint32_t *up = (uint32_t *) out; (void) cfg; (void) state; - if (! (ottery_get_cpu_capabilities_() & OTTERY_CPUCAP_RAND)) + if (! (ottery_get_cpu_capabilities_() & OTTERY_CPUCAP_RAND) || ottery_valgrind_) return OTTERY_ERR_INIT_STRONG_RNG; while (outlen >= 4) { if ((err = rdrand(up))) diff --git a/contrib/libottery/ottery_global.c b/contrib/libottery/ottery_global.c index 3c814f5ec..6bd205b4f 100644 --- a/contrib/libottery/ottery_global.c +++ b/contrib/libottery/ottery_global.c @@ -20,6 +20,7 @@ /** Flag: true iff ottery_global_state_ is initialized. */ static int ottery_global_state_initialized_ = 0; +int ottery_valgrind_ = 0; /** A global state to use for the ottery_* functions that don't take a * state. */ static struct ottery_state ottery_global_state_; @@ -41,6 +42,9 @@ ottery_init(const struct ottery_config *cfg) int n = ottery_st_init(&ottery_global_state_, cfg); if (n == 0) ottery_global_state_initialized_ = 1; + if (getenv("VALGRIND")) { + ottery_valgrind_ = 1; + } return n; } |