From: Richard Levitte Date: Thu, 6 Apr 2017 08:24:55 +0000 (+0200) Subject: In rand_cleanup_int(), don't go creating a default method X-Git-Tag: OpenSSL_1_1_1-pre1~1853 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=5006b37b31c5a520c3065048bd8aba8cc3ff128d In rand_cleanup_int(), don't go creating a default method If no default method was yet given, RAND_get_rand_method() will set it up. Doing so just to clean it away seems pretty silly, so instead, use the default_RAND_meth variable directly. This also clears a possible race condition where this will try to init things, such as ERR or ENGINE when in the middle of a OPENSSL_cleanup. Fixes #3128 Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/3136) --- diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index fc47dc97a2..ad452504e6 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -74,7 +74,7 @@ int RAND_set_rand_engine(ENGINE *engine) void rand_cleanup_int(void) { - const RAND_METHOD *meth = RAND_get_rand_method(); + const RAND_METHOD *meth = default_RAND_meth; if (meth && meth->cleanup) meth->cleanup(); RAND_set_rand_method(NULL);