Fix rand_lib.c for no-engine configuration
authorRichard Levitte <levitte@openssl.org>
Fri, 7 Apr 2017 14:26:10 +0000 (16:26 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 7 Apr 2017 14:33:39 +0000 (16:33 +0200)
When configured no-engine, we still refered to rand_engine_lock.
Rework the lock init code to avoid that.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3145)

crypto/rand/rand_lib.c

index dc629022c3f24198c08fb9b73e00a94828e2e687..40e2464a8258369fea549ad9ecc73f5b603d16c5 100644 (file)
@@ -26,11 +26,14 @@ static CRYPTO_ONCE rand_lock_init = CRYPTO_ONCE_STATIC_INIT;
 
 DEFINE_RUN_ONCE_STATIC(do_rand_lock_init)
 {
 
 DEFINE_RUN_ONCE_STATIC(do_rand_lock_init)
 {
+    int ret = 1;
 #ifndef OPENSSL_NO_ENGINE
     rand_engine_lock = CRYPTO_THREAD_lock_new();
 #ifndef OPENSSL_NO_ENGINE
     rand_engine_lock = CRYPTO_THREAD_lock_new();
+    ret &= rand_engine_lock != NULL;
 #endif
     rand_meth_lock = CRYPTO_THREAD_lock_new();
 #endif
     rand_meth_lock = CRYPTO_THREAD_lock_new();
-    return rand_engine_lock != NULL && rand_meth_lock != NULL;
+    ret &= rand_meth_lock != NULL;
+    return ret;
 }
 
 int RAND_set_rand_method(const RAND_METHOD *meth)
 }
 
 int RAND_set_rand_method(const RAND_METHOD *meth)