From 7d5491994e22f492d00afe1afdab5e22f5907093 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Fri, 27 Oct 2023 15:28:42 -0600 Subject: [PATCH] Fix for CID 299649 checking on if ctx is null --- src/ssl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index c9a373dbb..33b5927df 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -6464,7 +6464,8 @@ static int ProcessBufferTryDecodeRsa(WOLFSSL_CTX* ctx, WOLFSSL* ssl, #ifdef WOLF_PRIVATE_KEY_ID if ((ret != 0) && (devId != INVALID_DEVID #ifdef HAVE_PK_CALLBACKS - || wolfSSL_CTX_IsPrivatePkSet(ctx) + || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) : + wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) #endif )) { word32 nSz; @@ -6542,7 +6543,8 @@ static int ProcessBufferTryDecodeRsa(WOLFSSL_CTX* ctx, WOLFSSL* ssl, #ifdef WOLF_PRIVATE_KEY_ID if (ret != 0 && (devId != INVALID_DEVID #ifdef HAVE_PK_CALLBACKS - || wolfSSL_CTX_IsPrivatePkSet(ctx) + || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) : + wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) #endif )) { /* if using crypto or PK callbacks, try public key decode */ @@ -6623,7 +6625,8 @@ static int ProcessBufferTryDecodeEcc(WOLFSSL_CTX* ctx, WOLFSSL* ssl, #ifdef WOLF_PRIVATE_KEY_ID if (ret != 0 && (devId != INVALID_DEVID #ifdef HAVE_PK_CALLBACKS - || wolfSSL_CTX_IsPrivatePkSet(ctx) + || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) : + wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) #endif )) { /* if using crypto or PK callbacks, try public key decode */ @@ -6709,7 +6712,8 @@ static int ProcessBufferTryDecodeEd25519(WOLFSSL_CTX* ctx, WOLFSSL* ssl, #ifdef WOLF_PRIVATE_KEY_ID if (ret != 0 && (devId != INVALID_DEVID #ifdef HAVE_PK_CALLBACKS - || wolfSSL_CTX_IsPrivatePkSet(ctx) + || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) : + wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) #endif )) { /* if using crypto or PK callbacks, try public key decode */ @@ -6788,7 +6792,8 @@ static int ProcessBufferTryDecodeEd448(WOLFSSL_CTX* ctx, WOLFSSL* ssl, #ifdef WOLF_PRIVATE_KEY_ID if (ret != 0 && (devId != INVALID_DEVID #ifdef HAVE_PK_CALLBACKS - || wolfSSL_CTX_IsPrivatePkSet(ctx) + || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) : + wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) #endif )) { /* if using crypto or PK callbacks, try public key decode */