Skip to content

Commit 25cd009

Browse files
authored
Merge pull request #8695 from JacobBarthelmeh/coverity
null derefernce sanity checks and control flow issue
2 parents 3ca444e + d481086 commit 25cd009

5 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/internal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7306,6 +7306,8 @@ int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
73067306
ret = InitHandshakeHashes(ssl);
73077307
if (ret != 0) {
73087308
WOLFSSL_MSG_EX("InitHandshakeHashes failed. err = %d", ret);
7309+
ssl->hsHashes = tmpHashes; /* restore hsHashes pointer to original
7310+
* before returning */
73097311
return ret;
73107312
}
73117313

src/ssl_load.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
11121112
matchAnyKey = 1;
11131113
}
11141114
#ifdef WC_RSA_PSS
1115-
if(*keyFormat == RSAPSSk) {
1115+
if((ret == 0) && (*keyFormat == RSAPSSk)) {
11161116
/*
11171117
Require logic to verify that the der is RSAPSSk (when *keyFormat == RSAPSSK),
11181118
and to detect that the der is RSAPSSk (when *keyFormat == 0).

src/ssl_sess.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3534,6 +3534,10 @@ int wolfSSL_SESSION_get_master_key_length(const WOLFSSL_SESSION* ses)
35343534
#ifdef WOLFSSL_EARLY_DATA
35353535
unsigned int wolfSSL_SESSION_get_max_early_data(const WOLFSSL_SESSION *session)
35363536
{
3537+
if (session == NULL) {
3538+
return BAD_FUNC_ARG;
3539+
}
3540+
35373541
return session->maxEarlyDataSz;
35383542
}
35393543
#endif /* WOLFSSL_EARLY_DATA */

tests/quic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,9 @@ static int test_quic_early_data(int verbose) {
16751675
QuicTestContext_free(&tclient);
16761676
QuicTestContext_free(&tserver);
16771677

1678+
/* check for error value with null argument */
1679+
ExpectIntEQ(wolfSSL_SESSION_get_max_early_data(NULL), BAD_FUNC_ARG);
1680+
16781681
/* QUIC requires 0 or 0xffffffff as only allowed values.
16791682
* Since we enabled early data in the server that created the session,
16801683
* we need to see it here. */

wolfcrypt/src/hpke.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,10 @@ static int wc_HpkeContextComputeNonce(Hpke* hpke, HpkeBaseContext* context,
586586
int ret;
587587
byte seq_bytes[HPKE_Nn_MAX];
588588

589+
if (hpke == NULL || context == NULL) {
590+
return BAD_FUNC_ARG;
591+
}
592+
589593
/* convert the sequence into a byte string with the same length as the
590594
* nonce */
591595
ret = I2OSP(context->seq, (int)hpke->Nn, seq_bytes);

0 commit comments

Comments
 (0)