diff options
author | Matt Caswell <matt@openssl.org> | 2023-02-20 15:47:20 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-02-22 00:03:14 +0100 |
commit | 7a6a0baa591e3d04831ed0f468c72dc45feba452 (patch) | |
tree | bf0bdbb6382bdb90bcb06bba1df9c22d3332ed16 /crypto/property/property.c | |
parent | Document return value of OSSL_DECODER_from_data (diff) | |
download | openssl-7a6a0baa591e3d04831ed0f468c72dc45feba452.tar.xz openssl-7a6a0baa591e3d04831ed0f468c72dc45feba452.zip |
Only call OPENSSL_init_crypto on fetch if using the default libctx
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 https://github.com/openssl/openssl/pull/20341)
Diffstat (limited to 'crypto/property/property.c')
-rw-r--r-- | crypto/property/property.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/property/property.c b/crypto/property/property.c index 6f56d2366b..034cde51a8 100644 --- a/crypto/property/property.c +++ b/crypto/property/property.c @@ -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)) |