@@ -6464,7 +6464,8 @@ static int ProcessBufferTryDecodeRsa(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
64646464#ifdef WOLF_PRIVATE_KEY_ID
64656465 if ((ret != 0) && (devId != INVALID_DEVID
64666466 #ifdef HAVE_PK_CALLBACKS
6467- || wolfSSL_CTX_IsPrivatePkSet(ctx)
6467+ || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) :
6468+ wolfSSL_CTX_IsPrivatePkSet(ssl->ctx))
64686469 #endif
64696470 )) {
64706471 word32 nSz;
@@ -6542,7 +6543,8 @@ static int ProcessBufferTryDecodeRsa(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
65426543 #ifdef WOLF_PRIVATE_KEY_ID
65436544 if (ret != 0 && (devId != INVALID_DEVID
65446545 #ifdef HAVE_PK_CALLBACKS
6545- || wolfSSL_CTX_IsPrivatePkSet(ctx)
6546+ || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) :
6547+ wolfSSL_CTX_IsPrivatePkSet(ssl->ctx))
65466548 #endif
65476549 )) {
65486550 /* if using crypto or PK callbacks, try public key decode */
@@ -6623,7 +6625,8 @@ static int ProcessBufferTryDecodeEcc(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
66236625 #ifdef WOLF_PRIVATE_KEY_ID
66246626 if (ret != 0 && (devId != INVALID_DEVID
66256627 #ifdef HAVE_PK_CALLBACKS
6626- || wolfSSL_CTX_IsPrivatePkSet(ctx)
6628+ || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) :
6629+ wolfSSL_CTX_IsPrivatePkSet(ssl->ctx))
66276630 #endif
66286631 )) {
66296632 /* if using crypto or PK callbacks, try public key decode */
@@ -6709,7 +6712,8 @@ static int ProcessBufferTryDecodeEd25519(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
67096712 #ifdef WOLF_PRIVATE_KEY_ID
67106713 if (ret != 0 && (devId != INVALID_DEVID
67116714 #ifdef HAVE_PK_CALLBACKS
6712- || wolfSSL_CTX_IsPrivatePkSet(ctx)
6715+ || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) :
6716+ wolfSSL_CTX_IsPrivatePkSet(ssl->ctx))
67136717 #endif
67146718 )) {
67156719 /* if using crypto or PK callbacks, try public key decode */
@@ -6788,7 +6792,8 @@ static int ProcessBufferTryDecodeEd448(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
67886792 #ifdef WOLF_PRIVATE_KEY_ID
67896793 if (ret != 0 && (devId != INVALID_DEVID
67906794 #ifdef HAVE_PK_CALLBACKS
6791- || wolfSSL_CTX_IsPrivatePkSet(ctx)
6795+ || ((ssl == NULL) ? wolfSSL_CTX_IsPrivatePkSet(ctx) :
6796+ wolfSSL_CTX_IsPrivatePkSet(ssl->ctx))
67926797 #endif
67936798 )) {
67946799 /* if using crypto or PK callbacks, try public key decode */
@@ -29974,12 +29979,16 @@ static void SESSION_ex_data_cache_update(WOLFSSL_SESSION* session, int idx,
2997429979 #endif
2997529980 ) {
2997629981 if (get) {
29977- *getRet = wolfSSL_CRYPTO_get_ex_data(
29982+ if (getRet) {
29983+ *getRet = wolfSSL_CRYPTO_get_ex_data(
2997829984 &cacheSession->ex_data, idx);
29985+ }
2997929986 }
2998029987 else {
29981- *setRet = wolfSSL_CRYPTO_set_ex_data(
29988+ if (setRet) {
29989+ *setRet = wolfSSL_CRYPTO_set_ex_data(
2998229990 &cacheSession->ex_data, idx, data);
29991+ }
2998329992 }
2998429993 foundCache = 1;
2998529994 break;
@@ -36384,7 +36393,7 @@ static int wolfSSL_BIO_to_MIME_crlf(WOLFSSL_BIO* in, WOLFSSL_BIO* out)
3638436393#endif
3638536394 XMEMSET(line, 0, MAX_MIME_LINE_LEN);
3638636395
36387- while ((lineLen = wolfSSL_BIO_gets(in, line, (int)sizeof(line) )) > 0) {
36396+ while ((lineLen = wolfSSL_BIO_gets(in, line, MAX_MIME_LINE_LEN )) > 0) {
3638836397
3638936398 if (line[lineLen - 1] == '\r' || line[lineLen - 1] == '\n') {
3639036399 canonLineLen = (word32)lineLen;
@@ -36769,26 +36778,26 @@ int wolfSSL_PEM_write_bio_PKCS7(WOLFSSL_BIO* bio, PKCS7* p7)
3676936778 hashType = wc_OidGetHash(p7->hashOID);
3677036779 hashSz = wc_HashGetDigestSize(hashType);
3677136780 if (hashSz > WC_MAX_DIGEST_SIZE)
36772- return WOLFSSL_FAILURE ;
36781+ goto error ;
3677336782
3677436783 /* only SIGNED_DATA is supported */
3677536784 switch (p7->contentOID) {
3677636785 case SIGNED_DATA:
3677736786 break;
3677836787 default:
3677936788 WOLFSSL_MSG("Unknown PKCS#7 Type");
36780- return WOLFSSL_FAILURE ;
36789+ goto error ;
3678136790 };
3678236791
3678336792 if ((wc_PKCS7_EncodeSignedData_ex(p7, hashBuf, hashSz,
3678436793 outputHead, &outputHeadSz, outputFoot, &outputFootSz)) != 0)
36785- return WOLFSSL_FAILURE ;
36794+ goto error ;
3678636795
3678736796 outputSz = outputHeadSz + p7->contentSz + outputFootSz;
3678836797 output = (byte*)XMALLOC(outputSz, bio->heap, DYNAMIC_TYPE_TMP_BUFFER);
3678936798
3679036799 if (!output)
36791- return WOLFSSL_FAILURE ;
36800+ goto error ;
3679236801
3679336802 XMEMSET(output, 0, outputSz);
3679436803 outputSz = 0;
@@ -37177,6 +37186,8 @@ PKCS7* wolfSSL_SMIME_read_PKCS7(WOLFSSL_BIO* in,
3717737186 XFREE(section, NULL, DYNAMIC_TYPE_PKCS7);
3717837187 if (canonSection != NULL)
3717937188 XFREE(canonSection, NULL, DYNAMIC_TYPE_PKCS7);
37189+ if (canonLine != NULL)
37190+ XFREE(canonLine, NULL, DYNAMIC_TYPE_PKCS7);
3718037191 if (bcont) {
3718137192 wolfSSL_BIO_free(*bcont);
3718237193 *bcont = NULL; /* reset 'bcount' pointer to NULL on failure */
0 commit comments