Ensure we remove libctx DRBG state before removing the provider store
authorMatt Caswell <matt@openssl.org>
Thu, 17 Jun 2021 10:44:10 +0000 (11:44 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 21 Jun 2021 13:54:35 +0000 (14:54 +0100)
Otherwise a heap use-after-free can result.

Fixes #15766

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15810)

crypto/rand/rand_lib.c

index 62bd1d67967069c7661ab9bbfbed845f33991a57..8f76c8a5f024ec0c4abf5ef35ad334a38cec40d9 100644 (file)
@@ -492,7 +492,7 @@ static void rand_ossl_ctx_free(void *vdgbl)
 }
 
 static const OSSL_LIB_CTX_METHOD rand_drbg_ossl_ctx_method = {
-    OSSL_LIB_CTX_METHOD_DEFAULT_PRIORITY,
+    OSSL_LIB_CTX_METHOD_PRIORITY_2,
     rand_ossl_ctx_new,
     rand_ossl_ctx_free,
 };