Skip to content

Commit 1ccd462

Browse files
authored
Merge pull request #10482 from rlm2002/coverity
13052026 Coverity Fixes
2 parents bc2e842 + 4e0e189 commit 1ccd462

5 files changed

Lines changed: 21 additions & 35 deletions

File tree

src/ssl.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10154,18 +10154,10 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
1015410154
#endif
1015510155
#ifdef WOLFSSL_TLS13
1015610156
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
10157-
if (ssl->ctx != NULL) {
10158-
ssl->options.noPskDheKe = ssl->ctx->noPskDheKe;
10159-
#ifdef HAVE_SUPPORTED_CURVES
10160-
ssl->options.onlyPskDheKe = ssl->ctx->onlyPskDheKe;
10161-
#endif
10162-
}
10163-
else {
10164-
ssl->options.noPskDheKe = 0;
10165-
#ifdef HAVE_SUPPORTED_CURVES
10166-
ssl->options.onlyPskDheKe = 0;
10167-
#endif
10168-
}
10157+
ssl->options.noPskDheKe = ssl->ctx->noPskDheKe;
10158+
#ifdef HAVE_SUPPORTED_CURVES
10159+
ssl->options.onlyPskDheKe = ssl->ctx->onlyPskDheKe;
10160+
#endif
1016910161
#endif
1017010162
#endif
1017110163
#ifdef HAVE_SESSION_TICKET

tests/api.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23976,21 +23976,23 @@ static int test_ParseSerial0FixtureMatrix(void)
2397623976
ExpectIntGE(derSz = wc_CertPemToDer(pemBuf, (int)pemSz, derBuf,
2397723977
(int)pemSz, CERT_TYPE), 0);
2397823978

23979-
wc_InitDecodedCert(&dc, derBuf, (word32)derSz, NULL);
23980-
ret = wc_ParseCert(&dc, CERT_TYPE, NO_VERIFY, NULL);
23981-
if (cases[i].certTypeShouldPass)
23982-
ExpectIntEQ(ret, 0);
23983-
else
23984-
ExpectIntNE(ret, 0);
23985-
wc_FreeDecodedCert(&dc);
23979+
if (EXPECT_SUCCESS()) {
23980+
wc_InitDecodedCert(&dc, derBuf, (word32)derSz, NULL);
23981+
ret = wc_ParseCert(&dc, CERT_TYPE, NO_VERIFY, NULL);
23982+
if (cases[i].certTypeShouldPass)
23983+
ExpectIntEQ(ret, 0);
23984+
else
23985+
ExpectIntNE(ret, 0);
23986+
wc_FreeDecodedCert(&dc);
2398623987

23987-
wc_InitDecodedCert(&dc, derBuf, (word32)derSz, NULL);
23988-
ret = wc_ParseCert(&dc, CA_TYPE, NO_VERIFY, NULL);
23989-
if (cases[i].caTypeShouldPass)
23990-
ExpectIntEQ(ret, 0);
23991-
else
23992-
ExpectIntNE(ret, 0);
23993-
wc_FreeDecodedCert(&dc);
23988+
wc_InitDecodedCert(&dc, derBuf, (word32)derSz, NULL);
23989+
ret = wc_ParseCert(&dc, CA_TYPE, NO_VERIFY, NULL);
23990+
if (cases[i].caTypeShouldPass)
23991+
ExpectIntEQ(ret, 0);
23992+
else
23993+
ExpectIntNE(ret, 0);
23994+
wc_FreeDecodedCert(&dc);
23995+
}
2399423996

2399523997
XFREE(derBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
2399623998
XFREE(pemBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);

tests/api/api.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,6 @@ static WC_INLINE int test_pkcs8_get_version_byte(const byte* der, word32 derSz)
268268
if (der[idx++] != 0x30) {
269269
return -1;
270270
}
271-
if (idx >= derSz) {
272-
return -1;
273-
}
274271
if ((der[idx] & 0x80) == 0) {
275272
/* short-form length */
276273
idx += 1;

tests/api/test_camellia.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int test_wc_CamelliaFree(void)
126126
byte zero[sizeof(camellia)];
127127

128128
XMEMSET(zero, 0, sizeof(zero));
129+
XMEMSET(&camellia, 0, sizeof(camellia));
129130

130131
/* NULL is safe. */
131132
wc_CamelliaFree(NULL);

wolfcrypt/test/test.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31359,9 +31359,6 @@ static wc_test_ret_t openssl_aes_cbc_test(void)
3135931359
return WC_TEST_RET_ENC_NC;
3136031360
if (outlen != 16)
3136131361
return WC_TEST_RET_ENC_NC;
31362-
total += outlen;
31363-
if (total != 32)
31364-
return 3408;
3136531362

3136631363
wolfSSL_EVP_CIPHER_CTX_cleanup(en);
3136731364

@@ -31428,9 +31425,6 @@ static wc_test_ret_t openssl_aes_cbc_test(void)
3142831425
return WC_TEST_RET_ENC_NC;
3142931426
if (outlen != 16)
3143031427
return WC_TEST_RET_ENC_NC;
31431-
total += outlen;
31432-
if (total != 32)
31433-
return WC_TEST_RET_ENC_NC;
3143431428

3143531429
wolfSSL_EVP_CIPHER_CTX_cleanup(en);
3143631430

0 commit comments

Comments
 (0)