summaryrefslogtreecommitdiffstats
path: root/crypto/objects
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-03-31 10:35:32 +0100
committerTomas Mraz <tomas@openssl.org>2023-04-04 09:36:42 +0200
commit540c2d175d3c7c28bb969a74f6fe0396f0addc1a (patch)
treeff68b6a856901292fbe0209093f95800d34ed07d /crypto/objects
parent418c6c520764491262018c45481a20ef10cd3bca (diff)
Don't call OPENSSL_init_crypto from inside a RUN_ONCE
Calling OPENSSL_init_crypto from inside a RUN_ONCE seems like a bad idea. This is especially bad if OPENSSL_init_crypto can recursively end up attempting to call the RUN_ONCE that we're already inside. The initialisation in OPENSSL_init_crypto is already "run once" protected. There is no need to protect it "twice". Fixes #20653 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20662) (cherry picked from commit a9745427cd5d44a76b31690b4a2c6bef2ee677c4)
Diffstat (limited to 'crypto/objects')
-rw-r--r--crypto/objects/obj_dat.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c
index 466783d47f..0ef8330772 100644
--- a/crypto/objects/obj_dat.c
+++ b/crypto/objects/obj_dat.c
@@ -57,9 +57,6 @@ static ossl_inline void objs_free_locks(void)
DEFINE_RUN_ONCE_STATIC(obj_lock_initialise)
{
- /* Make sure we've loaded config before checking for any "added" objects */
- OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
-
ossl_obj_lock = CRYPTO_THREAD_lock_new();
if (ossl_obj_lock == NULL)
return 0;
@@ -76,6 +73,8 @@ DEFINE_RUN_ONCE_STATIC(obj_lock_initialise)
static ossl_inline int ossl_init_added_lock(void)
{
+ /* Make sure we've loaded config before checking for any "added" objects */
+ OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
return RUN_ONCE(&ossl_obj_lock_init, obj_lock_initialise);
}