summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorafshinpir <afshinpir@users.noreply.github.com>2024-02-28 16:58:03 +1300
committerTomas Mraz <tomas@openssl.org>2024-04-15 10:29:40 +0200
commit501caf05fe90d4631e5ef9291f2bba8aadd010c3 (patch)
treeb85d43234d19c6a5282e3d25fa0d224dfb07de7c
parent6cb91b331fea2e0c78eafb25ea636670e7a54d1a (diff)
Adding missing NULL pointer check
CLA: trivial In the provider store API, it is not necessary to provide both open and attach method at the same time and providing at least one of them is enough. Adding some null pointer checks to prevent exceptions in case of not providing both methods at the same time. Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23703) (cherry picked from commit bd73e1e62c4103e0faffb79cb3d34a2a92a95439)
-rw-r--r--crypto/store/store_lib.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c
index 05a8044f89..a801c28b9e 100644
--- a/crypto/store/store_lib.c
+++ b/crypto/store/store_lib.c
@@ -149,8 +149,8 @@ OSSL_STORE_open_ex(const char *uri, OSSL_LIB_CTX *libctx, const char *propq,
ossl_pw_passphrase_callback_dec,
&pwdata);
} else {
- loader_ctx = fetched_loader->p_open(provctx, uri);
- if (loader_ctx != NULL &&
+ if (fetched_loader->p_open != NULL &&
+ (loader_ctx = fetched_loader->p_open(provctx, uri)) != NULL &&
!loader_set_params(fetched_loader, loader_ctx,
params, propq)) {
(void)fetched_loader->p_close(loader_ctx);
@@ -1037,6 +1037,7 @@ OSSL_STORE_CTX *OSSL_STORE_attach(BIO *bp, const char *scheme,
OSSL_CORE_BIO *cbio = ossl_core_bio_new_from_bio(bp);
if (cbio == NULL
+ || fetched_loader->p_attach == NULL
|| (loader_ctx = fetched_loader->p_attach(provctx, cbio)) == NULL) {
OSSL_STORE_LOADER_free(fetched_loader);
fetched_loader = NULL;