Skip to content

Commit 294e4c7

Browse files
authored
Merge pull request #8578 from philljj/coverity_unchecked_ret
Coverity unchecked return value
2 parents 9258fde + 8d0931d commit 294e4c7

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

src/tls13.c

+15-10
Original file line numberDiff line numberDiff line change
@@ -4184,9 +4184,9 @@ static int EchHashHelloInner(WOLFSSL* ssl, WOLFSSL_ECH* ech)
41844184
tmpHashes = ssl->hsHashes;
41854185
ssl->hsHashes = NULL;
41864186
/* init the ech hashes */
4187-
InitHandshakeHashes(ssl);
4188-
ssl->hsHashesEch = ssl->hsHashes;
4187+
ret = InitHandshakeHashes(ssl);
41894188
if (ret == 0) {
4189+
ssl->hsHashesEch = ssl->hsHashes;
41904190
/* do the handshake header then the body */
41914191
AddTls13HandShakeHeader(falseHeader, realSz, 0, 0, client_hello, ssl);
41924192
ret = HashRaw(ssl, falseHeader, HANDSHAKE_HEADER_SZ);
@@ -4195,19 +4195,24 @@ static int EchHashHelloInner(WOLFSSL* ssl, WOLFSSL_ECH* ech)
41954195
/* init hsHashesEchInner */
41964196
if (ech->innerCount == 0) {
41974197
ssl->hsHashes = ssl->hsHashesEchInner;
4198-
InitHandshakeHashes(ssl);
4199-
ssl->hsHashesEchInner = ssl->hsHashes;
4200-
ech->innerCount = 1;
4198+
ret = InitHandshakeHashes(ssl);
4199+
if (ret == 0) {
4200+
ssl->hsHashesEchInner = ssl->hsHashes;
4201+
ech->innerCount = 1;
4202+
}
42014203
}
42024204
else {
42034205
/* switch back to hsHashes so we have hrr -> echInner2 */
42044206
ssl->hsHashes = tmpHashes;
4205-
InitHandshakeHashesAndCopy(ssl, ssl->hsHashes,
4206-
&ssl->hsHashesEchInner);
4207+
ret = InitHandshakeHashesAndCopy(ssl, ssl->hsHashes,
4208+
&ssl->hsHashesEchInner);
4209+
}
4210+
4211+
if (ret == 0) {
4212+
ssl->hsHashes = ssl->hsHashesEchInner;
4213+
ret = HashRaw(ssl, falseHeader, HANDSHAKE_HEADER_SZ);
4214+
ssl->hsHashes = ssl->hsHashesEch;
42074215
}
4208-
ssl->hsHashes = ssl->hsHashesEchInner;
4209-
ret = HashRaw(ssl, falseHeader, HANDSHAKE_HEADER_SZ);
4210-
ssl->hsHashes = ssl->hsHashesEch;
42114216
}
42124217
}
42134218
/* hash the body */

tests/api/test_dsa.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int test_wc_DsaSignVerify(void)
128128
#if !defined(HAVE_FIPS) && defined(WOLFSSL_PUBLIC_MP)
129129
/* hard set q to 0 and test fail case */
130130
mp_free(&key.q);
131-
mp_init(&key.q);
131+
ExpectIntEQ(mp_init(&key.q), 0);
132132
ExpectIntEQ(wc_DsaSign(hash, signature, &key, &rng), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
133133

134134
mp_set(&key.q, 1);

wolfcrypt/test/test.c

+18-6
Original file line numberDiff line numberDiff line change
@@ -55286,8 +55286,12 @@ static wc_test_ret_t mp_test_radix_16(mp_int* a, mp_int* r, WC_RNG* rng)
5528655286
ret = randNum(a, j, rng, NULL);
5528755287
if (ret != 0)
5528855288
return WC_TEST_RET_ENC_EC(ret);
55289-
mp_radix_size(a, MP_RADIX_HEX, &size);
55290-
mp_toradix(a, str, MP_RADIX_HEX);
55289+
ret = mp_radix_size(a, MP_RADIX_HEX, &size);
55290+
if (ret != 0)
55291+
return WC_TEST_RET_ENC_EC(ret);
55292+
ret = mp_toradix(a, str, MP_RADIX_HEX);
55293+
if (ret != 0)
55294+
return WC_TEST_RET_ENC_EC(ret);
5529155295
if ((int)XSTRLEN(str) != size - 1)
5529255296
return WC_TEST_RET_ENC_NC;
5529355297
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)
5536455368
if (ret != 0)
5536555369
return WC_TEST_RET_ENC_EC(ret);
5536655370
for (i = 0; i < 4; i++) {
55367-
mp_copy(r1, a);
55371+
ret = mp_copy(r1, a);
55372+
if (ret != MP_OKAY)
55373+
return WC_TEST_RET_ENC_EC(ret);
5536855374
#if !defined(NO_DH) || defined(HAVE_ECC) || (!defined(NO_RSA) && \
5536955375
defined(WC_RSA_BLINDING) && !defined(WOLFSSL_RSA_VERIFY_ONLY))
5537055376
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)
5678956795
ret = randNum(a, j, rng, NULL);
5679056796
if (ret != MP_OKAY)
5679156797
return WC_TEST_RET_ENC_EC(ret);
56792-
mp_copy(a, b);
56798+
ret = mp_copy(a, b);
56799+
if (ret != MP_OKAY)
56800+
return WC_TEST_RET_ENC_EC(ret);
5679356801
for (k = 0; k <= DIGIT_BIT * 2; k++) {
5679456802
ret = mp_mul_2d(a, k, a);
5679556803
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)
5680856816
ret = randNum(a, j, rng, NULL);
5680956817
if (ret != MP_OKAY)
5681056818
return WC_TEST_RET_ENC_EC(ret);
56811-
mp_copy(a, b);
56819+
ret = mp_copy(a, b);
56820+
if (ret != MP_OKAY)
56821+
return WC_TEST_RET_ENC_EC(ret);
5681256822
for (k = 0; k < 10; k++) {
5681356823
ret = mp_lshd(a, k);
5681456824
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)
5760257612
mp_mul_2d(b, DIGIT_BIT, b);
5760357613
mp_add_d(b, 1, b);
5760457614
mp_set(e, 0x3);
57605-
mp_copy(b, m);
57615+
ret = mp_copy(b, m);
57616+
if (ret != MP_OKAY)
57617+
return WC_TEST_RET_ENC_EC(ret);
5760657618
ret = mp_exptmod_ex(b, e, 1, m, r);
5760757619
if (ret != MP_OKAY)
5760857620
return WC_TEST_RET_ENC_EC(ret);

0 commit comments

Comments
 (0)