Skip to content

Commit f6ef58d

Browse files
authored
Merge pull request #7064 from philljj/fix_infer_issues
Fix issues from infer diff report.
2 parents 1b76f6d + a1b44b6 commit f6ef58d

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

src/quic.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,18 @@ int wolfSSL_quic_keys_active(WOLFSSL* ssl, enum encrypt_side side)
950950

951951
const WOLFSSL_EVP_CIPHER* wolfSSL_quic_get_aead(WOLFSSL* ssl)
952952
{
953-
WOLFSSL_CIPHER* cipher = wolfSSL_get_current_cipher(ssl);
954-
const WOLFSSL_EVP_CIPHER* evp_cipher;
953+
WOLFSSL_CIPHER* cipher = NULL;
954+
const WOLFSSL_EVP_CIPHER* evp_cipher = NULL;
955+
956+
if (ssl == NULL) {
957+
return NULL;
958+
}
959+
960+
cipher = wolfSSL_get_current_cipher(ssl);
961+
962+
if (cipher == NULL) {
963+
return NULL;
964+
}
955965

956966
switch (cipher->cipherSuite) {
957967
#if !defined(NO_AES) && defined(HAVE_AESGCM)
@@ -997,8 +1007,18 @@ static int evp_cipher_eq(const WOLFSSL_EVP_CIPHER* c1,
9971007

9981008
const WOLFSSL_EVP_CIPHER* wolfSSL_quic_get_hp(WOLFSSL* ssl)
9991009
{
1000-
WOLFSSL_CIPHER* cipher = wolfSSL_get_current_cipher(ssl);
1001-
const WOLFSSL_EVP_CIPHER* evp_cipher;
1010+
WOLFSSL_CIPHER* cipher = NULL;
1011+
const WOLFSSL_EVP_CIPHER* evp_cipher = NULL;
1012+
1013+
if (ssl == NULL) {
1014+
return NULL;
1015+
}
1016+
1017+
cipher = wolfSSL_get_current_cipher(ssl);
1018+
1019+
if (cipher == NULL) {
1020+
return NULL;
1021+
}
10021022

10031023
switch (cipher->cipherSuite) {
10041024
#if !defined(NO_AES) && defined(HAVE_AESGCM)

tests/api.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45099,8 +45099,8 @@ static int test_wolfSSL_cert_cb_dyn_ciphers_certCB(WOLFSSL* ssl, void* arg)
4509945099
haveECC = 0;
4510045100
}
4510145101
for (idx = 0; idx < hashSigAlgoSz; idx += 2) {
45102-
int hashAlgo;
45103-
int sigAlgo;
45102+
int hashAlgo = 0;
45103+
int sigAlgo = 0;
4510445104

4510545105
if (wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1],
4510645106
&hashAlgo, &sigAlgo) != 0)
@@ -45317,8 +45317,8 @@ static int test_wolfSSL_sigalg_info(void)
4531745317

4531845318
InitSuitesHashSigAlgo_ex2(hashSigAlgo, allSigAlgs, 1, 0xFFFFFFFF, &len);
4531945319
for (idx = 0; idx < len; idx += 2) {
45320-
int hashAlgo;
45321-
int sigAlgo;
45320+
int hashAlgo = 0;
45321+
int sigAlgo = 0;
4532245322

4532345323
ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0],
4532445324
hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0);
@@ -45330,8 +45330,8 @@ static int test_wolfSSL_sigalg_info(void)
4533045330
InitSuitesHashSigAlgo_ex2(hashSigAlgo, allSigAlgs | SIG_ANON, 1,
4533145331
0xFFFFFFFF, &len);
4533245332
for (idx = 0; idx < len; idx += 2) {
45333-
int hashAlgo;
45334-
int sigAlgo;
45333+
int hashAlgo = 0;
45334+
int sigAlgo = 0;
4533545335

4533645336
ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0],
4533745337
hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0);

tests/quic.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,11 @@ static int ctx_send_alert(WOLFSSL *ssl, WOLFSSL_ENCRYPTION_LEVEL level, uint8_t
543543
{
544544
QuicTestContext *ctx = (QuicTestContext*)wolfSSL_get_app_data(ssl);
545545

546+
AssertNotNull(ctx);
547+
546548
if (ctx->verbose) {
547549
printf("[%s] send_alert: level=%d, err=%d\n", ctx->name, level, err);
548550
}
549-
AssertNotNull(ctx);
550551
ctx->alert_level = level;
551552
ctx->alert = alert;
552553
return 1;
@@ -559,6 +560,8 @@ static int ctx_session_ticket_cb(WOLFSSL* ssl,
559560
{
560561
QuicTestContext *ctx = (QuicTestContext*)wolfSSL_get_app_data(ssl);
561562

563+
AssertNotNull(ctx);
564+
562565
(void)cb_ctx;
563566
if (ticketSz < 0 || (size_t)ticketSz > sizeof(ctx->ticket)) {
564567
printf("SESSION TICKET callback: ticket given is too large: %d bytes\n", ticketSz);
@@ -1535,6 +1538,8 @@ static int new_session_cb(WOLFSSL *ssl, WOLFSSL_SESSION *session)
15351538
int ret = 0;
15361539
int sz;
15371540

1541+
AssertNotNull(ctx);
1542+
15381543
sz = wolfSSL_i2d_SSL_SESSION(session, NULL);
15391544
if (sz <= 0) {
15401545
printf("[%s] session serialization error: %d <- ", ctx->name, sz);

wolfcrypt/src/rsa.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ static int RsaFunctionPrivate(mp_int* tmp, RsaKey* key, WC_RNG* rng)
24952495
{
24962496
int ret = 0;
24972497
#if defined(WC_RSA_BLINDING) && !defined(WC_NO_RNG)
2498-
mp_digit mp;
2498+
mp_digit mp = 0;
24992499
DECL_MP_INT_SIZE_DYN(rnd, mp_bitsused(&key->n), RSA_MAX_SIZE);
25002500
DECL_MP_INT_SIZE_DYN(rndi, mp_bitsused(&key->n), RSA_MAX_SIZE);
25012501
#endif /* WC_RSA_BLINDING && !WC_NO_RNG */

0 commit comments

Comments
 (0)