From 624233fb98e50b10808d231002c4b117d72d1494 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Wed, 5 Mar 2025 16:28:26 -0700 Subject: [PATCH] update test case to account for NO_DES3 build and resolve clang tidy warnings --- tests/api.c | 6 +++++- wolfcrypt/src/pkcs7.c | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/api.c b/tests/api.c index d56982cba..727abbd18 100644 --- a/tests/api.c +++ b/tests/api.c @@ -39268,7 +39268,11 @@ static int test_wc_PKCS7_DecodeEnvelopedData_stream(void) ret = wc_PKCS7_DecodeEnvelopedData(pkcs7, testStreamBuffer, testStreamBufferSz, NULL, 0); } while (ret == WC_NO_ERR_TRACE(WC_PKCS7_WANT_READ_E)); - ExpectIntGT(ret, 0); + #ifdef NO_DES3 + ExpectIntEQ(ret, ALGO_ID_E); + #else + ExpectIntGT(ret, 0); + #endif if (f != XBADFILE) { XFCLOSE(f); diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 772953211..5b5e569d1 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -12832,11 +12832,17 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(wc_PKCS7* pkcs7, byte* in, if (pkcs7->streamOutCb) { ret = pkcs7->streamOutCb(pkcs7, encryptedContent, encryptedContentSz - padLen, pkcs7->streamCtx); + if (ret != 0) { + WOLFSSL_MSG("Stream out callback returned failure"); + ret = BUFFER_E; + break; + } } else #endif /* ASN_BER_TO_DER */ { - if ((word32)(encryptedContentSz - padLen) > outputSz) { + if (output == NULL || (word32)(encryptedContentSz - padLen) > + outputSz) { ret = BUFFER_E; break; } @@ -13813,7 +13819,6 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(wc_PKCS7* pkcs7, byte* in, if (ret == 0 && GetASNTag(pkiMsg, &localIdx, &tag, pkiMsgSz) == 0 && tag == (ASN_CONSTRUCTED | ASN_CONTEXT_SPECIFIC | 1)) { encodedAttribIdx = idx; - encodedAttribs = pkiMsg + idx; idx++; if (GetLength_ex(pkiMsg, &idx, &length, pkiMsgSz, 0) <= 0) {