Merge pull request #7144 from bandi13/20240119-codesonar

20240119 codesonar
This commit is contained in:
David Garske
2024-01-19 09:35:02 -08:00
committed by GitHub
3 changed files with 27 additions and 5 deletions

View File

@@ -34558,9 +34558,11 @@ static int test_wolfSSL_tmp_dh(void)
BIO_free(bio); BIO_free(bio);
DSA_free(dsa); DSA_free(dsa);
DH_free(dh); DH_free(dh);
dh = NULL;
#if defined(WOLFSSL_DH_EXTRA) && \ #if defined(WOLFSSL_DH_EXTRA) && \
(defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH)) (defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH))
DH_free(dh2); DH_free(dh2);
dh2 = NULL;
#endif #endif
SSL_free(ssl); SSL_free(ssl);
SSL_CTX_free(ctx); SSL_CTX_free(ctx);
@@ -47143,6 +47145,7 @@ static int test_wolfSSL_PEM_read_DHparams(void)
XFCLOSE(fp); XFCLOSE(fp);
DH_free(dh); DH_free(dh);
dh = NULL;
#endif #endif
return EXPECT_RESULT(); return EXPECT_RESULT();
} }
@@ -47901,7 +47904,9 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_DH (void)
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
DH_free(setDh); DH_free(setDh);
setDh = NULL;
DH_free(dh); DH_free(dh);
dh = NULL;
#endif /* !NO_DH && WOLFSSL_DH_EXTRA && !NO_FILESYSTEM */ #endif /* !NO_DH && WOLFSSL_DH_EXTRA && !NO_FILESYSTEM */
#endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */
#endif /* OPENSSL_ALL || WOLFSSL_QT || WOLFSSL_OPENSSH */ #endif /* OPENSSL_ALL || WOLFSSL_QT || WOLFSSL_OPENSSH */
@@ -48071,6 +48076,7 @@ static int test_wolfSSL_CTX_ctrl(void)
BIO_free(bio); BIO_free(bio);
DSA_free(dsa); DSA_free(dsa);
DH_free(dh); DH_free(dh);
dh = NULL;
#endif #endif
#endif #endif
#ifdef HAVE_ECC #ifdef HAVE_ECC
@@ -48317,6 +48323,7 @@ static int test_wolfSSL_EVP_PKEY_keygen(void)
ASN1_INTEGER_free(asn1int); ASN1_INTEGER_free(asn1int);
DH_free(dh); DH_free(dh);
dh = NULL;
XFREE(derBuffer, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(derBuffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
@@ -48405,6 +48412,7 @@ static int test_wolfSSL_EVP_PKEY_copy_parameters(void)
ExpectIntEQ(BN_cmp(g1, g2), 0); ExpectIntEQ(BN_cmp(g1, g2), 0);
DH_free(dh); DH_free(dh);
dh = NULL;
EVP_PKEY_free(copy); EVP_PKEY_free(copy);
EVP_PKEY_free(params); EVP_PKEY_free(params);
#endif #endif
@@ -49150,7 +49158,9 @@ static int test_wolfSSL_EVP_PKEY_param_check(void)
EVP_PKEY_CTX_free(ctx); EVP_PKEY_CTX_free(ctx);
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
DH_free(setDh); DH_free(setDh);
setDh = NULL;
DH_free(dh); DH_free(dh);
dh = NULL;
#endif #endif
#endif #endif
return EXPECT_RESULT(); return EXPECT_RESULT();
@@ -58430,6 +58440,7 @@ static int test_wolfSSL_DH(void)
ExpectNotNull(dh = DH_generate_parameters(2048, 2, NULL, NULL)); ExpectNotNull(dh = DH_generate_parameters(2048, 2, NULL, NULL));
ExpectIntEQ(wolfSSL_DH_generate_parameters_ex(NULL, 2048, 2, NULL), 0); ExpectIntEQ(wolfSSL_DH_generate_parameters_ex(NULL, 2048, 2, NULL), 0);
DH_free(dh); DH_free(dh);
dh = NULL;
#endif #endif
#endif /* !HAVE_FIPS || (HAVE_FIPS_VERSION && HAVE_FIPS_VERSION > 2) */ #endif /* !HAVE_FIPS || (HAVE_FIPS_VERSION && HAVE_FIPS_VERSION > 2) */
#endif /* OPENSSL_ALL */ #endif /* OPENSSL_ALL */
@@ -58584,6 +58595,7 @@ static int test_wolfSSL_DH(void)
ExpectIntEQ(wolfSSL_DH_up_ref(dh), WOLFSSL_SUCCESS); ExpectIntEQ(wolfSSL_DH_up_ref(dh), WOLFSSL_SUCCESS);
DH_free(dh); /* decrease ref count */ DH_free(dh); /* decrease ref count */
DH_free(dh); /* free WOLFSSL_DH */ DH_free(dh); /* free WOLFSSL_DH */
dh = NULL;
q = NULL; q = NULL;
ExpectNull((dh = DH_new_by_nid(NID_sha1))); ExpectNull((dh = DH_new_by_nid(NID_sha1)));
@@ -58593,16 +58605,19 @@ static int test_wolfSSL_DH(void)
#ifdef HAVE_FFDHE_2048 #ifdef HAVE_FFDHE_2048
ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe2048))); ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe2048)));
DH_free(dh); DH_free(dh);
dh = NULL;
q = NULL; q = NULL;
#endif #endif
#ifdef HAVE_FFDHE_3072 #ifdef HAVE_FFDHE_3072
ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe3072))); ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe3072)));
DH_free(dh); DH_free(dh);
dh = NULL;
q = NULL; q = NULL;
#endif #endif
#ifdef HAVE_FFDHE_4096 #ifdef HAVE_FFDHE_4096
ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe4096))); ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe4096)));
DH_free(dh); DH_free(dh);
dh = NULL;
q = NULL; q = NULL;
#endif #endif
#else #else
@@ -58802,6 +58817,7 @@ static int test_wolfSSL_DH_check(void)
ExpectIntEQ(wolfSSL_DH_check(dh, NULL), 0); ExpectIntEQ(wolfSSL_DH_check(dh, NULL), 0);
ExpectIntEQ(codes, DH_CHECK_P_NOT_PRIME); ExpectIntEQ(codes, DH_CHECK_P_NOT_PRIME);
DH_free(dh); DH_free(dh);
dh = NULL;
#endif #endif
#endif /* !NO_DH && !NO_DSA */ #endif /* !NO_DH && !NO_DSA */
#endif #endif
@@ -59287,6 +59303,7 @@ static int test_wolfSSL_i2d_DHparams(void)
ExpectIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 268); ExpectIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 268);
DH_free(dh); DH_free(dh);
dh = NULL;
*buf = 0; *buf = 0;
#endif #endif
@@ -59316,6 +59333,7 @@ static int test_wolfSSL_i2d_DHparams(void)
ExpectIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 396); ExpectIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 396);
DH_free(dh); DH_free(dh);
dh = NULL;
#endif #endif
dh = DH_new(); dh = DH_new();
@@ -59323,6 +59341,7 @@ static int test_wolfSSL_i2d_DHparams(void)
pt2 = buf; pt2 = buf;
ExpectIntEQ(wolfSSL_i2d_DHparams(dh, &pt2), 0); ExpectIntEQ(wolfSSL_i2d_DHparams(dh, &pt2), 0);
DH_free(dh); DH_free(dh);
dh = NULL;
#endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */ #endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */
#endif /* !NO_DH && (HAVE_FFDHE_2048 || HAVE_FFDHE_3072) */ #endif /* !NO_DH && (HAVE_FFDHE_2048 || HAVE_FFDHE_3072) */
#endif #endif

View File

@@ -11103,6 +11103,7 @@ int wc_AesInit(Aes* aes, void* heap, int devId)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
aes->heap = heap; aes->heap = heap;
aes->rounds = 0;
#ifdef WOLF_CRYPTO_CB #ifdef WOLF_CRYPTO_CB
aes->devId = devId; aes->devId = devId;

View File

@@ -11489,8 +11489,13 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output,
return MEMORY_E; return MEMORY_E;
} }
FlattenAttributes(pkcs7, flatAuthAttribs, authAttribs, ret = FlattenAttributes(pkcs7, flatAuthAttribs, authAttribs,
authAttribsCount); authAttribsCount);
if (ret != 0) {
wc_PKCS7_FreeEncodedRecipientSet(pkcs7);
XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
return ret;
}
authAttribsSetSz = SetImplicit(ASN_SET, 1, authAttribsSz, authAttribsSetSz = SetImplicit(ASN_SET, 1, authAttribsSz,
authAttribSet); authAttribSet);
@@ -11825,10 +11830,6 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
} }
#endif #endif
#ifndef WOLFSSL_SMALL_STACK
XMEMSET(decryptedKey, 0, MAX_ENCRYPTED_KEY_SZ);
#endif
switch (pkcs7->state) { switch (pkcs7->state) {
case WC_PKCS7_START: case WC_PKCS7_START:
case WC_PKCS7_INFOSET_START: case WC_PKCS7_INFOSET_START:
@@ -11867,6 +11868,7 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
pkcs7->stream->key = decryptedKey; pkcs7->stream->key = decryptedKey;
#endif #endif
#endif #endif
XMEMSET(decryptedKey, 0, MAX_ENCRYPTED_KEY_SZ);
FALL_THROUGH; FALL_THROUGH;
case WC_PKCS7_DECRYPT_KTRI: case WC_PKCS7_DECRYPT_KTRI: