]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Revert "Return NULL from ossl_lib_ctx_get_concrete() when it is uninitialized"
authorTomas Mraz <tomas@openssl.org>
Wed, 8 Jan 2025 10:39:52 +0000 (11:39 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 8 Jan 2025 10:39:52 +0000 (11:39 +0100)
We do not have default_context_inited in 3.0 branch.

This reverts commit ed7651c93336049c2744327478f4d60bf9c21886.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26343)

crypto/context.c
crypto/rand/rand_lib.c

index 3ee2fcc3e78be6ddb6071a39b5b0ab23ccb4d051..ac6938e619eb1d93a9b6885c28477f7e45d0e32c 100644 (file)
@@ -47,23 +47,17 @@ struct ossl_lib_ctx_st {
 
 int ossl_lib_ctx_write_lock(OSSL_LIB_CTX *ctx)
 {
-    if ((ctx = ossl_lib_ctx_get_concrete(ctx)) == NULL)
-        return 0;
-    return CRYPTO_THREAD_write_lock(ctx->lock);
+    return CRYPTO_THREAD_write_lock(ossl_lib_ctx_get_concrete(ctx)->lock);
 }
 
 int ossl_lib_ctx_read_lock(OSSL_LIB_CTX *ctx)
 {
-    if ((ctx = ossl_lib_ctx_get_concrete(ctx)) == NULL)
-        return 0;
-    return CRYPTO_THREAD_read_lock(ctx->lock);
+    return CRYPTO_THREAD_read_lock(ossl_lib_ctx_get_concrete(ctx)->lock);
 }
 
 int ossl_lib_ctx_unlock(OSSL_LIB_CTX *ctx)
 {
-    if ((ctx = ossl_lib_ctx_get_concrete(ctx)) == NULL)
-        return 0;
-    return CRYPTO_THREAD_unlock(ctx->lock);
+    return CRYPTO_THREAD_unlock(ossl_lib_ctx_get_concrete(ctx)->lock);
 }
 
 int ossl_lib_ctx_is_child(OSSL_LIB_CTX *ctx)
@@ -179,7 +173,7 @@ static OSSL_LIB_CTX *get_default_context(void)
 {
     OSSL_LIB_CTX *current_defctx = get_thread_default_context();
 
-    if (current_defctx == NULL && default_context_inited)
+    if (current_defctx == NULL)
         current_defctx = &default_context_int;
     return current_defctx;
 }
index de576d252f23b6e2f4fd70143b0d98b46b400d62..5fde214448f3be78c06bd2a9e115fd39a9179ce5 100644 (file)
@@ -686,9 +686,6 @@ EVP_RAND_CTX *RAND_get0_public(OSSL_LIB_CTX *ctx)
             return NULL;
 
         ctx = ossl_lib_ctx_get_concrete(ctx);
-
-        if (ctx == NULL)
-            return NULL;
         /*
          * If the private is also NULL then this is the first time we've
          * used this thread.
@@ -722,9 +719,6 @@ EVP_RAND_CTX *RAND_get0_private(OSSL_LIB_CTX *ctx)
             return NULL;
 
         ctx = ossl_lib_ctx_get_concrete(ctx);
-
-        if (ctx == NULL)
-            return NULL;
         /*
          * If the public is also NULL then this is the first time we've
          * used this thread.