Skip to content

Commit

Permalink
Merge pull request #7064 from philljj/fix_infer_issues
Browse files Browse the repository at this point in the history
Fix issues from infer diff report.
  • Loading branch information
cconlon authored Dec 14, 2023
2 parents 1b76f6d + a1b44b6 commit f6ef58d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
28 changes: 24 additions & 4 deletions src/quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -45317,8 +45317,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);
Expand All @@ -45330,8 +45330,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);
Expand Down
7 changes: 6 additions & 1 deletion tests/quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/src/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ static int RsaFunctionPrivate(mp_int* tmp, RsaKey* key, WC_RNG* rng)
{
int ret = 0;
#if defined(WC_RSA_BLINDING) && !defined(WC_NO_RNG)
mp_digit mp;
mp_digit mp = 0;
DECL_MP_INT_SIZE_DYN(rnd, mp_bitsused(&key->n), RSA_MAX_SIZE);
DECL_MP_INT_SIZE_DYN(rndi, mp_bitsused(&key->n), RSA_MAX_SIZE);
#endif /* WC_RSA_BLINDING && !WC_NO_RNG */
Expand Down

0 comments on commit f6ef58d

Please sign in to comment.