Skip to content

Commit 02dfd12

Browse files
authored
Merge pull request wolfSSL#10376 from rlm2002/coverity
20260501 Coverity Fixes
2 parents 5ffdb9f + 3b00b05 commit 02dfd12

3 files changed

Lines changed: 16 additions & 21 deletions

File tree

tests/api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10621,7 +10621,8 @@ static int test_tls_ext_word16_overflow(void)
1062110621
ExpectIntEQ(TLSX_UseSessionTicket(&ssl->extensions, ticket, ssl->heap),
1062210622
WOLFSSL_SUCCESS);
1062310623
/* TLSX_UseSessionTicket takes ownership on success. */
10624-
ticket = NULL;
10624+
if (EXPECT_SUCCESS())
10625+
ticket = NULL;
1062510626
}
1062610627

1062710628
/* TLSX_GetRequestSize must refuse to encode: 4-byte ext header +
@@ -10697,7 +10698,8 @@ static int test_tls_ext_word16_overflow(void)
1069710698
if (EXPECT_SUCCESS() && ticket2 != NULL) {
1069810699
ExpectIntEQ(TLSX_UseSessionTicket(&ssl2->extensions, ticket2,
1069910700
ssl2->heap), WOLFSSL_SUCCESS);
10700-
ticket2 = NULL;
10701+
if (EXPECT_SUCCESS())
10702+
ticket2 = NULL;
1070110703
}
1070210704

1070310705
/* Exact boundary: internal sum == 0xFFFD must succeed, and the

tests/api/test_pkcs12.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ int test_wc_PKCS12_encrypted_content_bounds(void)
434434
word32 regPkeySz = 0;
435435
word32 regCertSz = 0;
436436

437+
XMEMSET(regCiphertext, 0, sizeof(regCiphertext));
437438
/* Derive AES-256 key with the same PBKDF2 that DecryptContent uses */
438439
ExpectIntEQ(wc_PBKDF2(regKey, (const byte*)regPassword,
439440
(int)XSTRLEN(regPassword), regSalt, (int)sizeof(regSalt),

wolfcrypt/src/rsa.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,39 +1154,31 @@ static int RsaMGF_SHAKE(enum wc_HashType shakeType, byte* seed, word32 seedSz,
11541154
return MEMORY_E);
11551155

11561156
#ifdef WOLFSSL_SHAKE128
1157-
if (shakeType == WC_HASH_TYPE_SHAKE128)
1157+
if (shakeType == WC_HASH_TYPE_SHAKE128) {
11581158
ret = wc_InitShake128(shake, heap, INVALID_DEVID);
1159-
else
1160-
#endif
1161-
#ifdef WOLFSSL_SHAKE256
1162-
if (shakeType == WC_HASH_TYPE_SHAKE256)
1163-
ret = wc_InitShake256(shake, heap, INVALID_DEVID);
1164-
else
1165-
#endif
1166-
ret = BAD_FUNC_ARG;
1167-
1168-
if (ret == 0) {
1169-
#ifdef WOLFSSL_SHAKE128
1170-
if (shakeType == WC_HASH_TYPE_SHAKE128) {
1159+
if (ret == 0) {
11711160
ret = wc_Shake128_Update(shake, seed, seedSz);
11721161
if (ret == 0)
11731162
ret = wc_Shake128_Final(shake, out, outSz);
11741163
wc_Shake128_Free(shake);
11751164
}
1176-
else
1165+
}
1166+
else
11771167
#endif
11781168
#ifdef WOLFSSL_SHAKE256
1179-
if (shakeType == WC_HASH_TYPE_SHAKE256) {
1169+
if (shakeType == WC_HASH_TYPE_SHAKE256) {
1170+
ret = wc_InitShake256(shake, heap, INVALID_DEVID);
1171+
if (ret == 0) {
11801172
ret = wc_Shake256_Update(shake, seed, seedSz);
11811173
if (ret == 0)
11821174
ret = wc_Shake256_Final(shake, out, outSz);
11831175
wc_Shake256_Free(shake);
11841176
}
1185-
else
1177+
}
1178+
else
11861179
#endif
1187-
{
1188-
ret = BAD_FUNC_ARG;
1189-
}
1180+
{
1181+
ret = BAD_FUNC_ARG;
11901182
}
11911183
WC_FREE_VAR_EX(shake, heap, DYNAMIC_TYPE_TMP_BUFFER);
11921184
return ret;

0 commit comments

Comments
 (0)