Skip to content

Commit

Permalink
FAPI: Fix possible null pointer access in fapi crypto.
Browse files Browse the repository at this point in the history
In the cleanup function for an ossl hash context the variables
were not checked before calling the ossl cleanup functions.

Signed-off-by: Juergen Repp <[email protected]>
  • Loading branch information
JuergenReppSIT committed Feb 26, 2024
1 parent 5e41bbe commit 20643e9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/tss2-fapi/fapi_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ ifapi_crypto_context_free(IFAPI_CRYPTO_CONTEXT *ctx)
if (!ctx)
return;

EVP_MD_CTX_destroy(ctx->osslContext);
if (ctx->osslContext) {
EVP_MD_CTX_destroy(ctx->osslContext);
}
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
EVP_MD_free(ctx->osslHashAlgorithm);
OSSL_LIB_CTX_free(ctx->libctx);
if (ctx->osslHashAlgorithm) {
EVP_MD_free(ctx->osslHashAlgorithm);
}
if (ctx->libctx) {
OSSL_LIB_CTX_free(ctx->libctx);
}
#endif
SAFE_FREE(ctx);
}
Expand Down

0 comments on commit 20643e9

Please sign in to comment.