Browse Source

Fix issues from infer diff report.

jordan 4 months ago
parent
commit
f222adf4c2
3 changed files with 36 additions and 11 deletions
  1. 24 4
      src/quic.c
  2. 6 6
      tests/api.c
  3. 6 1
      tests/quic.c

+ 24 - 4
src/quic.c

@@ -950,8 +950,18 @@ cleanup:
 
 const WOLFSSL_EVP_CIPHER* wolfSSL_quic_get_aead(WOLFSSL* ssl)
 {
-    WOLFSSL_CIPHER* cipher = wolfSSL_get_current_cipher(ssl);
-    const WOLFSSL_EVP_CIPHER* evp_cipher;
+    WOLFSSL_CIPHER* cipher = NULL;
+    const WOLFSSL_EVP_CIPHER* evp_cipher = NULL;
+
+    if (ssl == NULL) {
+        return NULL;
+    }
+
+    cipher = wolfSSL_get_current_cipher(ssl);
+
+    if (cipher == NULL) {
+        return NULL;
+    }
 
     switch (cipher->cipherSuite) {
 #if !defined(NO_AES) && defined(HAVE_AESGCM)
@@ -997,8 +1007,18 @@ static int evp_cipher_eq(const WOLFSSL_EVP_CIPHER* c1,
 
 const WOLFSSL_EVP_CIPHER* wolfSSL_quic_get_hp(WOLFSSL* ssl)
 {
-    WOLFSSL_CIPHER* cipher = wolfSSL_get_current_cipher(ssl);
-    const WOLFSSL_EVP_CIPHER* evp_cipher;
+    WOLFSSL_CIPHER* cipher = NULL;
+    const WOLFSSL_EVP_CIPHER* evp_cipher = NULL;
+
+    if (ssl == NULL) {
+        return NULL;
+    }
+
+    cipher = wolfSSL_get_current_cipher(ssl);
+
+    if (cipher == NULL) {
+        return NULL;
+    }
 
     switch (cipher->cipherSuite) {
 #if !defined(NO_AES) && defined(HAVE_AESGCM)

+ 6 - 6
tests/api.c

@@ -45099,8 +45099,8 @@ static int test_wolfSSL_cert_cb_dyn_ciphers_certCB(WOLFSSL* ssl, void* arg)
         haveECC = 0;
     }
     for (idx = 0; idx < hashSigAlgoSz; idx += 2) {
-        int hashAlgo;
-        int sigAlgo;
+        int hashAlgo = 0;
+        int sigAlgo = 0;
 
         if (wolfSSL_get_sigalg_info(hashSigAlgo[idx+0], hashSigAlgo[idx+1],
                 &hashAlgo, &sigAlgo) != 0)
@@ -45313,8 +45313,8 @@ static int test_wolfSSL_sigalg_info(void)
 
     InitSuitesHashSigAlgo_ex2(hashSigAlgo, allSigAlgs, 1, 0xFFFFFFFF, &len);
     for (idx = 0; idx < len; idx += 2) {
-        int hashAlgo;
-        int sigAlgo;
+        int hashAlgo = 0;
+        int sigAlgo = 0;
 
         ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0],
                 hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0);
@@ -45326,8 +45326,8 @@ static int test_wolfSSL_sigalg_info(void)
     InitSuitesHashSigAlgo_ex2(hashSigAlgo, allSigAlgs | SIG_ANON, 1,
             0xFFFFFFFF, &len);
     for (idx = 0; idx < len; idx += 2) {
-        int hashAlgo;
-        int sigAlgo;
+        int hashAlgo = 0;
+        int sigAlgo = 0;
 
         ExpectIntEQ(wolfSSL_get_sigalg_info(hashSigAlgo[idx+0],
                 hashSigAlgo[idx+1], &hashAlgo, &sigAlgo), 0);

+ 6 - 1
tests/quic.c

@@ -543,10 +543,11 @@ static int ctx_send_alert(WOLFSSL *ssl, WOLFSSL_ENCRYPTION_LEVEL level, uint8_t
 {
     QuicTestContext *ctx = (QuicTestContext*)wolfSSL_get_app_data(ssl);
 
+    AssertNotNull(ctx);
+
     if (ctx->verbose) {
         printf("[%s] send_alert: level=%d, err=%d\n", ctx->name, level, err);
     }
-    AssertNotNull(ctx);
     ctx->alert_level = level;
     ctx->alert = alert;
     return 1;
@@ -559,6 +560,8 @@ static int ctx_session_ticket_cb(WOLFSSL* ssl,
 {
     QuicTestContext *ctx = (QuicTestContext*)wolfSSL_get_app_data(ssl);
 
+    AssertNotNull(ctx);
+
     (void)cb_ctx;
     if (ticketSz < 0 || (size_t)ticketSz > sizeof(ctx->ticket)) {
         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)
     int ret = 0;
     int sz;
 
+    AssertNotNull(ctx);
+
     sz = wolfSSL_i2d_SSL_SESSION(session, NULL);
     if (sz <= 0) {
         printf("[%s] session serialization error: %d <- ", ctx->name, sz);