Skip to content

Commit

Permalink
Only call OPENSSL_init_crypto on fetch if using the default libctx
Browse files Browse the repository at this point in the history
There is no point in calling OPENSSL_init_crypto() unless we are actually
going to be using the default libctx.

Fixes #20315

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #20341)

(cherry picked from commit 7a6a0ba)
  • Loading branch information
mattcaswell authored and paulidale committed Feb 21, 2023
1 parent a57ab43 commit ba8e207
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crypto/property/property.c
Expand Up @@ -502,13 +502,14 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
int ret = 0;
int j, best = -1, score, optional;

#ifndef FIPS_MODULE
if (!OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL))
if (nid <= 0 || method == NULL || store == NULL)
return 0;
#endif

if (nid <= 0 || method == NULL || store == NULL)
#ifndef FIPS_MODULE
if (ossl_lib_ctx_is_default(store->ctx)
&& !OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL))
return 0;
#endif

/* This only needs to be a read lock, because the query won't create anything */
if (!ossl_property_read_lock(store))
Expand Down

0 comments on commit ba8e207

Please sign in to comment.