src/internal.c: fixes for cppcheck complaints: nullPointerRedundantCheck uninitvar

This commit is contained in:
Daniel Pouzzner
2022-01-08 00:27:47 -06:00
parent ff4c6e5d7b
commit b69dc00bd7

View File

@ -1640,8 +1640,8 @@ int wolfSSL_session_import_internal(WOLFSSL* ssl, const unsigned char* buf,
word32 idx = 0; word32 idx = 0;
word16 length = 0; word16 length = 0;
int version = 0; int version = 0;
int ret = 0; int ret = BAD_FUNC_ARG;
int optSz; int optSz = 0;
int rc; int rc;
byte validProto = 0; /* did we find a valid protocol */ byte validProto = 0; /* did we find a valid protocol */
@ -1825,8 +1825,8 @@ int wolfSSL_session_import_internal(WOLFSSL* ssl, const unsigned char* buf,
#ifndef WOLFSSL_AEAD_ONLY #ifndef WOLFSSL_AEAD_ONLY
/* set hmac function to use when verifying */ /* set hmac function to use when verifying */
if (ssl->options.tls == 1 || ssl->options.tls1_1 == 1 || if (ret == 0 && (ssl->options.tls == 1 || ssl->options.tls1_1 == 1 ||
ssl->options.dtls == 1) { ssl->options.dtls == 1)) {
#if !defined(WOLFSSL_RENESAS_SCEPROTECT) && \ #if !defined(WOLFSSL_RENESAS_SCEPROTECT) && \
!defined(WOLFSSL_RENESAS_TSIP_TLS) !defined(WOLFSSL_RENESAS_TSIP_TLS)
ssl->hmac = TLS_hmac; ssl->hmac = TLS_hmac;
@ -4318,7 +4318,7 @@ int RsaSign(WOLFSSL* ssl, const byte* in, word32 inSz, byte* out,
int RsaVerify(WOLFSSL* ssl, byte* in, word32 inSz, byte** out, int sigAlgo, int RsaVerify(WOLFSSL* ssl, byte* in, word32 inSz, byte** out, int sigAlgo,
int hashAlgo, RsaKey* key, buffer* keyBufInfo) int hashAlgo, RsaKey* key, buffer* keyBufInfo)
{ {
int ret; int ret = SIG_VERIFY_E;
#ifdef HAVE_PK_CALLBACKS #ifdef HAVE_PK_CALLBACKS
const byte* keyBuf = NULL; const byte* keyBuf = NULL;
@ -4592,7 +4592,7 @@ int RsaDec(WOLFSSL* ssl, byte* in, word32 inSz, byte** out, word32* outSz,
int RsaEnc(WOLFSSL* ssl, const byte* in, word32 inSz, byte* out, word32* outSz, int RsaEnc(WOLFSSL* ssl, const byte* in, word32 inSz, byte* out, word32* outSz,
RsaKey* key, buffer* keyBufInfo) RsaKey* key, buffer* keyBufInfo)
{ {
int ret; int ret = BAD_FUNC_ARG;
#ifdef HAVE_PK_CALLBACKS #ifdef HAVE_PK_CALLBACKS
const byte* keyBuf = NULL; const byte* keyBuf = NULL;
word32 keySz = 0; word32 keySz = 0;
@ -4710,7 +4710,7 @@ int EccSign(WOLFSSL* ssl, const byte* in, word32 inSz, byte* out,
int EccVerify(WOLFSSL* ssl, const byte* in, word32 inSz, const byte* out, int EccVerify(WOLFSSL* ssl, const byte* in, word32 inSz, const byte* out,
word32 outSz, ecc_key* key, buffer* keyBufInfo) word32 outSz, ecc_key* key, buffer* keyBufInfo)
{ {
int ret; int ret = SIG_VERIFY_E;
#ifdef HAVE_PK_CALLBACKS #ifdef HAVE_PK_CALLBACKS
const byte* keyBuf = NULL; const byte* keyBuf = NULL;
word32 keySz = 0; word32 keySz = 0;
@ -21475,9 +21475,6 @@ const char* GetCipherEncStr(char n[][MAX_SEGMENT_SZ]) {
int IsCipherAEAD(char n[][MAX_SEGMENT_SZ]) int IsCipherAEAD(char n[][MAX_SEGMENT_SZ])
{ {
const char *n1,*n2,*n3; const char *n1,*n2,*n3;
n1 = n[1];
n2 = n[2];
n3 = n[3];
WOLFSSL_ENTER("IsCipherAEAD"); WOLFSSL_ENTER("IsCipherAEAD");
@ -21486,6 +21483,10 @@ int IsCipherAEAD(char n[][MAX_SEGMENT_SZ])
return 0; return 0;
} }
n1 = n[1];
n2 = n[2];
n3 = n[3];
if ((XSTRNCMP(n2,"GCM",3) == 0) || (XSTRNCMP(n3,"GCM",3) == 0) || if ((XSTRNCMP(n2,"GCM",3) == 0) || (XSTRNCMP(n3,"GCM",3) == 0) ||
(XSTRNCMP(n1,"CCM",3) == 0) || (XSTRNCMP(n1,"CCM",3) == 0) ||
(XSTRNCMP(n2,"CCM",3) == 0) || (XSTRNCMP(n3,"CCM",3) == 0) || (XSTRNCMP(n2,"CCM",3) == 0) || (XSTRNCMP(n3,"CCM",3) == 0) ||
@ -22820,9 +22821,7 @@ exit_dpk:
byte *output; byte *output;
word32 length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; word32 length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ;
int sendSz; int sendSz;
int idSz = ssl->options.resuming int idSz;
? ssl->session.sessionIDSz
: 0;
int ret; int ret;
word16 extSz = 0; word16 extSz = 0;
@ -22830,6 +22829,8 @@ exit_dpk:
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
} }
idSz = ssl->options.resuming ? ssl->session.sessionIDSz : 0;
#ifdef WOLFSSL_TLS13 #ifdef WOLFSSL_TLS13
if (IsAtLeastTLSv1_3(ssl->version)) if (IsAtLeastTLSv1_3(ssl->version))
return SendTls13ClientHello(ssl); return SendTls13ClientHello(ssl);