diff --git a/src/quic.c b/src/quic.c index 0a60f57673..02622a7e47 100644 --- a/src/quic.c +++ b/src/quic.c @@ -950,8 +950,18 @@ int wolfSSL_quic_keys_active(WOLFSSL* ssl, enum encrypt_side side) 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) diff --git a/tests/api.c b/tests/api.c index 4e19c9b499..95d9999842 100644 --- a/tests/api.c +++ b/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); diff --git a/tests/quic.c b/tests/quic.c index a03c685277..a044343994 100644 --- a/tests/quic.c +++ b/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);