Skip to content

Commit 6b8280f

Browse files
authored
Merge pull request #7144 from bandi13/20240119-codesonar
20240119 codesonar
2 parents a3a7012 + dbc209d commit 6b8280f

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

tests/api.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34558,9 +34558,11 @@ static int test_wolfSSL_tmp_dh(void)
3455834558
BIO_free(bio);
3455934559
DSA_free(dsa);
3456034560
DH_free(dh);
34561+
dh = NULL;
3456134562
#if defined(WOLFSSL_DH_EXTRA) && \
3456234563
(defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH))
3456334564
DH_free(dh2);
34565+
dh2 = NULL;
3456434566
#endif
3456534567
SSL_free(ssl);
3456634568
SSL_CTX_free(ctx);
@@ -47143,6 +47145,7 @@ static int test_wolfSSL_PEM_read_DHparams(void)
4714347145
XFCLOSE(fp);
4714447146

4714547147
DH_free(dh);
47148+
dh = NULL;
4714647149
#endif
4714747150
return EXPECT_RESULT();
4714847151
}
@@ -47901,7 +47904,9 @@ static int test_wolfSSL_EVP_PKEY_set1_get1_DH (void)
4790147904

4790247905
EVP_PKEY_free(pkey);
4790347906
DH_free(setDh);
47907+
setDh = NULL;
4790447908
DH_free(dh);
47909+
dh = NULL;
4790547910
#endif /* !NO_DH && WOLFSSL_DH_EXTRA && !NO_FILESYSTEM */
4790647911
#endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */
4790747912
#endif /* OPENSSL_ALL || WOLFSSL_QT || WOLFSSL_OPENSSH */
@@ -48071,6 +48076,7 @@ static int test_wolfSSL_CTX_ctrl(void)
4807148076
BIO_free(bio);
4807248077
DSA_free(dsa);
4807348078
DH_free(dh);
48079+
dh = NULL;
4807448080
#endif
4807548081
#endif
4807648082
#ifdef HAVE_ECC
@@ -48317,6 +48323,7 @@ static int test_wolfSSL_EVP_PKEY_keygen(void)
4831748323

4831848324
ASN1_INTEGER_free(asn1int);
4831948325
DH_free(dh);
48326+
dh = NULL;
4832048327
XFREE(derBuffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
4832148328

4832248329
EVP_PKEY_free(pkey);
@@ -48405,6 +48412,7 @@ static int test_wolfSSL_EVP_PKEY_copy_parameters(void)
4840548412
ExpectIntEQ(BN_cmp(g1, g2), 0);
4840648413

4840748414
DH_free(dh);
48415+
dh = NULL;
4840848416
EVP_PKEY_free(copy);
4840948417
EVP_PKEY_free(params);
4841048418
#endif
@@ -49150,7 +49158,9 @@ static int test_wolfSSL_EVP_PKEY_param_check(void)
4915049158
EVP_PKEY_CTX_free(ctx);
4915149159
EVP_PKEY_free(pkey);
4915249160
DH_free(setDh);
49161+
setDh = NULL;
4915349162
DH_free(dh);
49163+
dh = NULL;
4915449164
#endif
4915549165
#endif
4915649166
return EXPECT_RESULT();
@@ -58430,6 +58440,7 @@ static int test_wolfSSL_DH(void)
5843058440
ExpectNotNull(dh = DH_generate_parameters(2048, 2, NULL, NULL));
5843158441
ExpectIntEQ(wolfSSL_DH_generate_parameters_ex(NULL, 2048, 2, NULL), 0);
5843258442
DH_free(dh);
58443+
dh = NULL;
5843358444
#endif
5843458445
#endif /* !HAVE_FIPS || (HAVE_FIPS_VERSION && HAVE_FIPS_VERSION > 2) */
5843558446
#endif /* OPENSSL_ALL */
@@ -58584,6 +58595,7 @@ static int test_wolfSSL_DH(void)
5858458595
ExpectIntEQ(wolfSSL_DH_up_ref(dh), WOLFSSL_SUCCESS);
5858558596
DH_free(dh); /* decrease ref count */
5858658597
DH_free(dh); /* free WOLFSSL_DH */
58598+
dh = NULL;
5858758599
q = NULL;
5858858600

5858958601
ExpectNull((dh = DH_new_by_nid(NID_sha1)));
@@ -58593,16 +58605,19 @@ static int test_wolfSSL_DH(void)
5859358605
#ifdef HAVE_FFDHE_2048
5859458606
ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe2048)));
5859558607
DH_free(dh);
58608+
dh = NULL;
5859658609
q = NULL;
5859758610
#endif
5859858611
#ifdef HAVE_FFDHE_3072
5859958612
ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe3072)));
5860058613
DH_free(dh);
58614+
dh = NULL;
5860158615
q = NULL;
5860258616
#endif
5860358617
#ifdef HAVE_FFDHE_4096
5860458618
ExpectNotNull((dh = DH_new_by_nid(NID_ffdhe4096)));
5860558619
DH_free(dh);
58620+
dh = NULL;
5860658621
q = NULL;
5860758622
#endif
5860858623
#else
@@ -58802,6 +58817,7 @@ static int test_wolfSSL_DH_check(void)
5880258817
ExpectIntEQ(wolfSSL_DH_check(dh, NULL), 0);
5880358818
ExpectIntEQ(codes, DH_CHECK_P_NOT_PRIME);
5880458819
DH_free(dh);
58820+
dh = NULL;
5880558821
#endif
5880658822
#endif /* !NO_DH && !NO_DSA */
5880758823
#endif
@@ -59287,6 +59303,7 @@ static int test_wolfSSL_i2d_DHparams(void)
5928759303
ExpectIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 268);
5928859304

5928959305
DH_free(dh);
59306+
dh = NULL;
5929059307

5929159308
*buf = 0;
5929259309
#endif
@@ -59316,13 +59333,15 @@ static int test_wolfSSL_i2d_DHparams(void)
5931659333
ExpectIntEQ(wolfSSL_i2d_DHparams(dh, NULL), 396);
5931759334

5931859335
DH_free(dh);
59336+
dh = NULL;
5931959337
#endif
5932059338

5932159339
dh = DH_new();
5932259340
ExpectNotNull(dh);
5932359341
pt2 = buf;
5932459342
ExpectIntEQ(wolfSSL_i2d_DHparams(dh, &pt2), 0);
5932559343
DH_free(dh);
59344+
dh = NULL;
5932659345
#endif /* !HAVE_FIPS || HAVE_FIPS_VERSION > 2 */
5932759346
#endif /* !NO_DH && (HAVE_FFDHE_2048 || HAVE_FFDHE_3072) */
5932859347
#endif

wolfcrypt/src/aes.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11103,6 +11103,7 @@ int wc_AesInit(Aes* aes, void* heap, int devId)
1110311103
return BAD_FUNC_ARG;
1110411104

1110511105
aes->heap = heap;
11106+
aes->rounds = 0;
1110611107

1110711108
#ifdef WOLF_CRYPTO_CB
1110811109
aes->devId = devId;

wolfcrypt/src/pkcs7.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11489,8 +11489,13 @@ int wc_PKCS7_EncodeAuthEnvelopedData(PKCS7* pkcs7, byte* output,
1148911489
return MEMORY_E;
1149011490
}
1149111491

11492-
FlattenAttributes(pkcs7, flatAuthAttribs, authAttribs,
11492+
ret = FlattenAttributes(pkcs7, flatAuthAttribs, authAttribs,
1149311493
authAttribsCount);
11494+
if (ret != 0) {
11495+
wc_PKCS7_FreeEncodedRecipientSet(pkcs7);
11496+
XFREE(flatAuthAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
11497+
return ret;
11498+
}
1149411499

1149511500
authAttribsSetSz = SetImplicit(ASN_SET, 1, authAttribsSz,
1149611501
authAttribSet);
@@ -11825,10 +11830,6 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
1182511830
}
1182611831
#endif
1182711832

11828-
#ifndef WOLFSSL_SMALL_STACK
11829-
XMEMSET(decryptedKey, 0, MAX_ENCRYPTED_KEY_SZ);
11830-
#endif
11831-
1183211833
switch (pkcs7->state) {
1183311834
case WC_PKCS7_START:
1183411835
case WC_PKCS7_INFOSET_START:
@@ -11867,6 +11868,7 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
1186711868
pkcs7->stream->key = decryptedKey;
1186811869
#endif
1186911870
#endif
11871+
XMEMSET(decryptedKey, 0, MAX_ENCRYPTED_KEY_SZ);
1187011872
FALL_THROUGH;
1187111873

1187211874
case WC_PKCS7_DECRYPT_KTRI:

0 commit comments

Comments
 (0)