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)
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;
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);
}