Merge pull request #8578 from philljj/coverity_unchecked_ret

Coverity unchecked return value
pull/8553/head
David Garske 2025-03-21 10:05:29 -07:00 committed by GitHub
commit 294e4c79a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 17 deletions

View File

@ -4184,9 +4184,9 @@ static int EchHashHelloInner(WOLFSSL* ssl, WOLFSSL_ECH* ech)
tmpHashes = ssl->hsHashes;
ssl->hsHashes = NULL;
/* init the ech hashes */
InitHandshakeHashes(ssl);
ssl->hsHashesEch = ssl->hsHashes;
ret = InitHandshakeHashes(ssl);
if (ret == 0) {
ssl->hsHashesEch = ssl->hsHashes;
/* do the handshake header then the body */
AddTls13HandShakeHeader(falseHeader, realSz, 0, 0, client_hello, ssl);
ret = HashRaw(ssl, falseHeader, HANDSHAKE_HEADER_SZ);
@ -4195,21 +4195,26 @@ static int EchHashHelloInner(WOLFSSL* ssl, WOLFSSL_ECH* ech)
/* init hsHashesEchInner */
if (ech->innerCount == 0) {
ssl->hsHashes = ssl->hsHashesEchInner;
InitHandshakeHashes(ssl);
ret = InitHandshakeHashes(ssl);
if (ret == 0) {
ssl->hsHashesEchInner = ssl->hsHashes;
ech->innerCount = 1;
}
}
else {
/* switch back to hsHashes so we have hrr -> echInner2 */
ssl->hsHashes = tmpHashes;
InitHandshakeHashesAndCopy(ssl, ssl->hsHashes,
ret = InitHandshakeHashesAndCopy(ssl, ssl->hsHashes,
&ssl->hsHashesEchInner);
}
if (ret == 0) {
ssl->hsHashes = ssl->hsHashesEchInner;
ret = HashRaw(ssl, falseHeader, HANDSHAKE_HEADER_SZ);
ssl->hsHashes = ssl->hsHashesEch;
}
}
}
/* hash the body */
if (ret == 0)
ret = HashRaw(ssl, ech->innerClientHello, realSz);

View File

@ -128,7 +128,7 @@ int test_wc_DsaSignVerify(void)
#if !defined(HAVE_FIPS) && defined(WOLFSSL_PUBLIC_MP)
/* hard set q to 0 and test fail case */
mp_free(&key.q);
mp_init(&key.q);
ExpectIntEQ(mp_init(&key.q), 0);
ExpectIntEQ(wc_DsaSign(hash, signature, &key, &rng), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
mp_set(&key.q, 1);

View File

@ -55286,8 +55286,12 @@ static wc_test_ret_t mp_test_radix_16(mp_int* a, mp_int* r, WC_RNG* rng)
ret = randNum(a, j, rng, NULL);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
mp_radix_size(a, MP_RADIX_HEX, &size);
mp_toradix(a, str, MP_RADIX_HEX);
ret = mp_radix_size(a, MP_RADIX_HEX, &size);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ret = mp_toradix(a, str, MP_RADIX_HEX);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
if ((int)XSTRLEN(str) != size - 1)
return WC_TEST_RET_ENC_NC;
mp_read_radix(r, str, MP_RADIX_HEX);
@ -55364,7 +55368,9 @@ static wc_test_ret_t mp_test_shift(mp_int* a, mp_int* r1, WC_RNG* rng)
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
for (i = 0; i < 4; i++) {
mp_copy(r1, a);
ret = mp_copy(r1, a);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);
#if !defined(NO_DH) || defined(HAVE_ECC) || (!defined(NO_RSA) && \
defined(WC_RSA_BLINDING) && !defined(WOLFSSL_RSA_VERIFY_ONLY))
ret = mp_lshd(r1, i);
@ -56789,7 +56795,9 @@ static wc_test_ret_t mp_test_shbd(mp_int* a, mp_int* b, WC_RNG* rng)
ret = randNum(a, j, rng, NULL);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);
mp_copy(a, b);
ret = mp_copy(a, b);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);
for (k = 0; k <= DIGIT_BIT * 2; k++) {
ret = mp_mul_2d(a, k, a);
if (ret != MP_OKAY)
@ -56808,7 +56816,9 @@ static wc_test_ret_t mp_test_shbd(mp_int* a, mp_int* b, WC_RNG* rng)
ret = randNum(a, j, rng, NULL);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);
mp_copy(a, b);
ret = mp_copy(a, b);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);
for (k = 0; k < 10; k++) {
ret = mp_lshd(a, k);
if (ret != MP_OKAY)
@ -57602,7 +57612,9 @@ static wc_test_ret_t mp_test_exptmod(mp_int* b, mp_int* e, mp_int* m, mp_int* r)
mp_mul_2d(b, DIGIT_BIT, b);
mp_add_d(b, 1, b);
mp_set(e, 0x3);
mp_copy(b, m);
ret = mp_copy(b, m);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);
ret = mp_exptmod_ex(b, e, 1, m, r);
if (ret != MP_OKAY)
return WC_TEST_RET_ENC_EC(ret);