Skip to content

Commit

Permalink
Adding missing NULL pointer check
Browse files Browse the repository at this point in the history
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 #23703)

(cherry picked from commit bd73e1e)
  • Loading branch information
afshinpir authored and t8m committed Apr 15, 2024
1 parent 6cb91b3 commit 501caf0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crypto/store/store_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 501caf0

Please sign in to comment.