Merge pull request #2738 from SparkiDev/cppcheck_fixes_3

Changes to clear issues raised by cppcheck
This commit is contained in:
Chris Conlon
2020-02-03 17:02:40 -07:00
committed by GitHub
63 changed files with 896 additions and 922 deletions

View File

@@ -457,7 +457,7 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len)
}
/* check for formatting */
if (bio && bio->type == WOLFSSL_BIO_BASE64) {
if (bio->type == WOLFSSL_BIO_BASE64) {
#if defined(WOLFSSL_BASE64_ENCODE)
word32 sz = 0;
@@ -527,7 +527,7 @@ int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len)
#ifndef WOLFCRYPT_ONLY
if (bio && bio->type == WOLFSSL_BIO_SSL) {
/* already got eof, again is error */
if (bio && front->eof) {
if (front->eof) {
ret = SSL_FATAL_ERROR;
}
else {

View File

@@ -201,8 +201,6 @@ static int CheckCertCRLList(WOLFSSL_CRL* crl, DecodedCert* cert, int *pFoundEntr
while (crle) {
if (XMEMCMP(crle->issuerHash, cert->issuerHash, CRL_DIGEST_SIZE) == 0) {
int doNextDate = 1;
WOLFSSL_MSG("Found CRL Entry on list");
if (crle->verified == 0) {
@@ -211,7 +209,7 @@ static int CheckCertCRLList(WOLFSSL_CRL* crl, DecodedCert* cert, int *pFoundEntr
byte extAuthKeyId[KEYID_SIZE];
#endif
byte issuerHash[CRL_DIGEST_SIZE];
byte* tbs = NULL;
byte* tbs;
word32 tbsSz = crle->tbsSz;
byte* sig = NULL;
word32 sigSz = crle->signatureSz;
@@ -297,12 +295,10 @@ static int CheckCertCRLList(WOLFSSL_CRL* crl, DecodedCert* cert, int *pFoundEntr
WOLFSSL_MSG("Checking next date validity");
#ifdef WOLFSSL_NO_CRL_NEXT_DATE
if (crle->nextDateFormat == ASN_OTHER_TYPE)
doNextDate = 0; /* skip */
#endif
if (doNextDate) {
#ifdef WOLFSSL_NO_CRL_NEXT_DATE
if (crle->nextDateFormat != ASN_OTHER_TYPE)
#endif
{
#ifndef NO_ASN_TIME
if (!XVALIDATE_DATE(crle->nextDate,crle->nextDateFormat, AFTER)) {
WOLFSSL_MSG("CRL next date is no longer valid");

View File

@@ -259,7 +259,6 @@ static int QSH_FreeAll(WOLFSSL* ssl)
/* free struct */
XFREE(preKey, ssl->heap, DYNAMIC_TYPE_QSH);
}
key = NULL;
/* free all of peers QSH keys */
@@ -1793,7 +1792,8 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
/* In case contexts are held in array and don't want to free actual ctx */
void SSL_CtxResourceFree(WOLFSSL_CTX* ctx)
{
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) && !defined(NO_WOLFSSL_SERVER)
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) && \
defined(HAVE_TLS_EXTENSIONS) && !defined(NO_WOLFSSL_SERVER)
int i;
#endif
@@ -6372,7 +6372,7 @@ static WC_INLINE void WriteSEQ(WOLFSSL* ssl, int verifyOrder, byte* out)
* extra space for the headers. */
DtlsMsg* DtlsMsgNew(word32 sz, void* heap)
{
DtlsMsg* msg = NULL;
DtlsMsg* msg;
(void)heap;
msg = (DtlsMsg*)XMALLOC(sizeof(DtlsMsg), heap, DYNAMIC_TYPE_DTLS_MSG);
@@ -9473,7 +9473,7 @@ int DoVerifyCallback(WOLFSSL_CERT_MANAGER* cm, WOLFSSL* ssl, int ret,
#endif
))
#ifndef NO_WOLFSSL_CM_VERIFY
|| ((cm != NULL) && (cm->verifyCallback != NULL))
|| (cm->verifyCallback != NULL)
#endif
) {
int verifyFail = 0;
@@ -15466,7 +15466,7 @@ int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
if (ssl->truncated_hmac &&
ssl->specs.hash_size > args->digestSz) {
#ifdef WOLFSSL_SMALL_STACK
byte* hmac = NULL;
byte* hmac;
#else
byte hmac[WC_MAX_DIGEST_SIZE];
#endif
@@ -16458,7 +16458,7 @@ int SendCertificateStatus(WOLFSSL* ssl)
buffer der;
word32 idx = 0;
#ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert = NULL;
DecodedCert* cert;
#else
DecodedCert cert[1];
#endif
@@ -20787,7 +20787,7 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input,
{
if (IsAtLeastTLSv1_2(ssl)) {
#ifdef WOLFSSL_SMALL_STACK
byte* encodedSig = NULL;
byte* encodedSig;
#else
byte encodedSig[MAX_ENCODED_SIG_SZ];
#endif
@@ -22604,7 +22604,7 @@ int SendCertificateVerify(WOLFSSL* ssl)
}
}
if (args->length <= 0) {
if (args->length == 0) {
ERROR_OUT(NO_PRIVATE_KEY, exit_scv);
}
@@ -23964,7 +23964,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
#ifdef HAVE_PK_CALLBACKS
if (wolfSSL_CTX_IsPrivatePkSet(ssl->ctx)) {
args->tmpSigSz = GetPrivateKeySigSize(ssl);
if (args->tmpSigSz <= 0) {
if (args->tmpSigSz == 0) {
ERROR_OUT(NO_PRIVATE_KEY, exit_sske);
}
}
@@ -24250,7 +24250,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
}
}
if (keySz <= 0) { /* test if keySz has error */
if (keySz == 0) { /* test if keySz has error */
ERROR_OUT(keySz, exit_sske);
}
@@ -26210,7 +26210,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
#endif
{
#ifdef WOLFSSL_SMALL_STACK
byte* encodedSig = NULL;
byte* encodedSig;
#else
byte encodedSig[MAX_ENCODED_SIG_SZ];
#endif

View File

@@ -835,7 +835,7 @@ void wolfSSL_OCSP_REQUEST_free(OcspRequest* request)
int wolfSSL_i2d_OCSP_REQUEST(OcspRequest* request, unsigned char** data)
{
word32 size;
int size;
size = EncodeOcspRequest(request, NULL, 0);
if (size <= 0 || data == NULL)

204
src/ssl.c
View File

@@ -676,7 +676,7 @@ WOLFSSL* wolfSSL_write_dup(WOLFSSL* ssl)
if ( (ret = InitSSL(dup, ssl->ctx, 1)) < 0) {
FreeSSL(dup, ssl->ctx->heap);
dup = NULL;
} else if ( (ret = DupSSL(dup, ssl) < 0)) {
} else if ( (ret = DupSSL(dup, ssl)) < 0) {
FreeSSL(dup, ssl->ctx->heap);
dup = NULL;
}
@@ -1370,55 +1370,55 @@ WC_RNG* wolfSSL_GetRNG(WOLFSSL* ssl)
int wolfSSL_GetObjectSize(void)
{
#ifdef SHOW_SIZES
printf("sizeof suites = %lu\n", sizeof(Suites));
printf("sizeof ciphers(2) = %lu\n", sizeof(Ciphers));
printf("sizeof suites = %lu\n", (unsigned long)sizeof(Suites));
printf("sizeof ciphers(2) = %lu\n", (unsigned long)sizeof(Ciphers));
#ifndef NO_RC4
printf("\tsizeof arc4 = %lu\n", sizeof(Arc4));
printf("\tsizeof arc4 = %lu\n", (unsigned long)sizeof(Arc4));
#endif
printf("\tsizeof aes = %lu\n", sizeof(Aes));
printf("\tsizeof aes = %lu\n", (unsigned long)sizeof(Aes));
#ifndef NO_DES3
printf("\tsizeof des3 = %lu\n", sizeof(Des3));
printf("\tsizeof des3 = %lu\n", (unsigned long)sizeof(Des3));
#endif
#ifndef NO_RABBIT
printf("\tsizeof rabbit = %lu\n", sizeof(Rabbit));
printf("\tsizeof rabbit = %lu\n", (unsigned long)sizeof(Rabbit));
#endif
#ifdef HAVE_CHACHA
printf("\tsizeof chacha = %lu\n", sizeof(ChaCha));
printf("\tsizeof chacha = %lu\n", (unsigned long)sizeof(ChaCha));
#endif
printf("sizeof cipher specs = %lu\n", sizeof(CipherSpecs));
printf("sizeof keys = %lu\n", sizeof(Keys));
printf("sizeof Hashes(2) = %lu\n", sizeof(Hashes));
printf("sizeof cipher specs = %lu\n", (unsigned long)sizeof(CipherSpecs));
printf("sizeof keys = %lu\n", (unsigned long)sizeof(Keys));
printf("sizeof Hashes(2) = %lu\n", (unsigned long)sizeof(Hashes));
#ifndef NO_MD5
printf("\tsizeof MD5 = %lu\n", sizeof(wc_Md5));
printf("\tsizeof MD5 = %lu\n", (unsigned long)sizeof(wc_Md5));
#endif
#ifndef NO_SHA
printf("\tsizeof SHA = %lu\n", sizeof(wc_Sha));
printf("\tsizeof SHA = %lu\n", (unsigned long)sizeof(wc_Sha));
#endif
#ifdef WOLFSSL_SHA224
printf("\tsizeof SHA224 = %lu\n", sizeof(wc_Sha224));
printf("\tsizeof SHA224 = %lu\n", (unsigned long)sizeof(wc_Sha224));
#endif
#ifndef NO_SHA256
printf("\tsizeof SHA256 = %lu\n", sizeof(wc_Sha256));
printf("\tsizeof SHA256 = %lu\n", (unsigned long)sizeof(wc_Sha256));
#endif
#ifdef WOLFSSL_SHA384
printf("\tsizeof SHA384 = %lu\n", sizeof(wc_Sha384));
printf("\tsizeof SHA384 = %lu\n", (unsigned long)sizeof(wc_Sha384));
#endif
#ifdef WOLFSSL_SHA384
printf("\tsizeof SHA512 = %lu\n", sizeof(wc_Sha512));
printf("\tsizeof SHA512 = %lu\n", (unsigned long)sizeof(wc_Sha512));
#endif
printf("sizeof Buffers = %lu\n", sizeof(Buffers));
printf("sizeof Options = %lu\n", sizeof(Options));
printf("sizeof Arrays = %lu\n", sizeof(Arrays));
printf("sizeof Buffers = %lu\n", (unsigned long)sizeof(Buffers));
printf("sizeof Options = %lu\n", (unsigned long)sizeof(Options));
printf("sizeof Arrays = %lu\n", (unsigned long)sizeof(Arrays));
#ifndef NO_RSA
printf("sizeof RsaKey = %lu\n", sizeof(RsaKey));
printf("sizeof RsaKey = %lu\n", (unsigned long)sizeof(RsaKey));
#endif
#ifdef HAVE_ECC
printf("sizeof ecc_key = %lu\n", sizeof(ecc_key));
printf("sizeof ecc_key = %lu\n", (unsigned long)sizeof(ecc_key));
#endif
printf("sizeof WOLFSSL_CIPHER = %lu\n", sizeof(WOLFSSL_CIPHER));
printf("sizeof WOLFSSL_SESSION = %lu\n", sizeof(WOLFSSL_SESSION));
printf("sizeof WOLFSSL = %lu\n", sizeof(WOLFSSL));
printf("sizeof WOLFSSL_CTX = %lu\n", sizeof(WOLFSSL_CTX));
printf("sizeof WOLFSSL_CIPHER = %lu\n", (unsigned long)sizeof(WOLFSSL_CIPHER));
printf("sizeof WOLFSSL_SESSION = %lu\n", (unsigned long)sizeof(WOLFSSL_SESSION));
printf("sizeof WOLFSSL = %lu\n", (unsigned long)sizeof(WOLFSSL));
printf("sizeof WOLFSSL_CTX = %lu\n", (unsigned long)sizeof(WOLFSSL_CTX));
#endif
return sizeof(WOLFSSL);
@@ -1704,15 +1704,19 @@ int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz,
ssl->options.haveDH = 1;
if (ssl->options.side != WOLFSSL_NEITHER_END) {
word16 havePSK = 0;
word16 haveRSA = 1;
word16 havePSK;
word16 haveRSA;
int keySz = 0;
#ifndef NO_PSK
havePSK = ssl->options.havePSK;
#else
havePSK = 0;
#endif
#ifdef NO_RSA
haveRSA = 0;
#else
haveRSA = 1;
#endif
#ifndef NO_CERTS
keySz = ssl->buffers.keySz;
@@ -2478,7 +2482,7 @@ int wolfSSL_UseALPN(WOLFSSL* ssl, char *protocol_name_list,
/* read all protocol name from the list */
token[idx] = XSTRTOK(list, ",", &ptr);
while (token[idx] != NULL && idx < WOLFSSL_MAX_ALPN_NUMBER)
while (idx < WOLFSSL_MAX_ALPN_NUMBER && token[idx] != NULL)
token[++idx] = XSTRTOK(NULL, ",", &ptr);
/* add protocol name list in the TLS extension in reverse order */
@@ -3453,7 +3457,7 @@ WOLFSSL_CERT_MANAGER* wolfSSL_CTX_GetCertManager(WOLFSSL_CTX* ctx)
WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew_ex(void* heap)
{
WOLFSSL_CERT_MANAGER* cm = NULL;
WOLFSSL_CERT_MANAGER* cm;
WOLFSSL_ENTER("wolfSSL_CertManagerNew");
@@ -4657,7 +4661,7 @@ int AddTrustedPeer(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int verify)
{
int ret, row;
TrustedPeerCert* peerCert;
DecodedCert* cert = NULL;
DecodedCert* cert;
DerBuffer* der = *pDer;
byte* subjectHash = NULL;
@@ -4953,10 +4957,10 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
if ( ret == 0 && signer != NULL ) {
signer->cm_idx = row;
if (type == WOLFSSL_USER_CA && tsip_rootCAverified() == 0 ) {
if (ret = tsip_tls_RootCertVerify(cert->source, cert->maxIdx,
cert->sigCtx.pubkey_n_start, cert->sigCtx.pubkey_n_len - 1,
cert->sigCtx.pubkey_e_start, cert->sigCtx.pubkey_e_len - 1,
row/* cm index */)
if ((ret = tsip_tls_RootCertVerify(cert->source, cert->maxIdx,
cert->sigCtx.pubkey_n_start, cert->sigCtx.pubkey_n_len - 1,
cert->sigCtx.pubkey_e_start, cert->sigCtx.pubkey_e_len - 1,
row/* cm index */))
!= 0)
WOLFSSL_MSG("tsip_tls_RootCertVerify() failed");
else
@@ -5268,15 +5272,15 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der
(void)devId;
if (ctx == NULL && ssl == NULL)
return BAD_FUNC_ARG;
ret = BAD_FUNC_ARG;
if (!der || !keySz || !idx || !resetSuites || !keyFormat)
return BAD_FUNC_ARG;
ret = BAD_FUNC_ARG;
#ifndef NO_RSA
if (ret == 0 && (*keyFormat == 0 || *keyFormat == RSAk)) {
/* make sure RSA key can be used */
#ifdef WOLFSSL_SMALL_STACK
RsaKey* key = NULL;
RsaKey* key;
#else
RsaKey key[1];
#endif
@@ -5311,7 +5315,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der
ssl->buffers.keyType = rsa_sa_algo;
ssl->buffers.keySz = *keySz;
}
else if(ctx) {
else {
ctx->privateKeyType = rsa_sa_algo;
ctx->privateKeySz = *keySz;
}
@@ -5336,7 +5340,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der
if (ret == 0 && (*keyFormat == 0 || *keyFormat == ECDSAk)) {
/* make sure ECC key can be used */
#ifdef WOLFSSL_SMALL_STACK
ecc_key* key = NULL;
ecc_key* key;
#else
ecc_key key[1];
#endif
@@ -5366,7 +5370,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der
ssl->buffers.keyType = ecc_dsa_sa_algo;
ssl->buffers.keySz = *keySz;
}
else if (ctx) {
else {
ctx->haveStaticECC = 1;
ctx->privateKeyType = ecc_dsa_sa_algo;
ctx->privateKeySz = *keySz;
@@ -5389,7 +5393,7 @@ static int ProcessBufferTryDecode(WOLFSSL_CTX* ctx, WOLFSSL* ssl, DerBuffer* der
if (ret == 0 && (*keyFormat == 0 || *keyFormat == ED25519k)) {
/* make sure Ed25519 key can be used */
#ifdef WOLFSSL_SMALL_STACK
ed25519_key* key = NULL;
ed25519_key* key;
#else
ed25519_key key[1];
#endif
@@ -5726,7 +5730,7 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff,
}
else if (type == CERT_TYPE) {
#ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert = NULL;
DecodedCert* cert;
#else
DecodedCert cert[1];
#endif
@@ -6246,7 +6250,7 @@ int CM_VerifyBuffer_ex(WOLFSSL_CERT_MANAGER* cm, const byte* buff,
int ret = 0;
DerBuffer* der = NULL;
#ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert = NULL;
DecodedCert* cert;
#else
DecodedCert cert[1];
#endif
@@ -6298,7 +6302,7 @@ int CM_VerifyBuffer_ex(WOLFSSL_CERT_MANAGER* cm, const byte* buff,
if (cm->verifyCallback) {
buffer certBuf;
#ifdef WOLFSSL_SMALL_STACK
ProcPeerCertArgs* args = NULL;
ProcPeerCertArgs* args;
args = (ProcPeerCertArgs*)XMALLOC(
sizeof(ProcPeerCertArgs), cm->heap, DYNAMIC_TYPE_TMP_BUFFER);
if (args == NULL) {
@@ -6826,7 +6830,7 @@ int wolfSSL_CTX_load_verify_locations_ex(WOLFSSL_CTX* ctx, const char* file,
#ifndef NO_WOLFSSL_DIR
char* name = NULL;
#ifdef WOLFSSL_SMALL_STACK
ReadDirCtx* readCtx = NULL;
ReadDirCtx* readCtx;
readCtx = (ReadDirCtx*)XMALLOC(sizeof(ReadDirCtx), ctx->heap,
DYNAMIC_TYPE_DIRCTX);
if (readCtx == NULL)
@@ -8668,8 +8672,7 @@ WOLFSSL_X509_EXTENSION* wolfSSL_X509_set_ext(WOLFSSL_X509* x509, int loc)
/* Set object size and reallocate space in object buffer */
ext->obj->objSz = objSz;
if(((ext->obj->dynamic & WOLFSSL_ASN1_DYNAMIC_DATA) != 0) ||
(((ext->obj->dynamic & WOLFSSL_ASN1_DYNAMIC_DATA) == 0) &&
(ext->obj->obj == NULL))) {
(ext->obj->obj == NULL)) {
ext->obj->obj =(byte*)XREALLOC((byte*)ext->obj->obj,
ext->obj->objSz,
NULL,DYNAMIC_TYPE_ASN1);
@@ -9336,7 +9339,7 @@ int wolfSSL_ASN1_BIT_STRING_get_bit(const WOLFSSL_ASN1_BIT_STRING* str, int i)
return WOLFSSL_FAILURE;
}
return str->data[i/8] & (1<<(7-(i%8))) ? 1 : 0;
return (str->data[i/8] & (1<<(7-(i%8)))) ? 1 : 0;
}
/* Looks for the extension matching the passed in nid
@@ -11629,16 +11632,17 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
}
WOLFSSL_METHOD* wolfSSLv23_method_ex(void* heap)
{
WOLFSSL_METHOD* m = NULL;
WOLFSSL_METHOD* m;
WOLFSSL_ENTER("SSLv23_method");
#if !defined(NO_WOLFSSL_CLIENT)
m = wolfSSLv23_client_method_ex(heap);
m->side = WOLFSSL_NEITHER_END;
#elif !defined(NO_WOLFSSL_SERVER)
m = wolfSSLv23_server_method_ex(heap);
m->side = WOLFSSL_NEITHER_END;
#else
m = NULL;
#endif
if (m != NULL) {
m->side = WOLFSSL_NEITHER_END;
}
return m;
}
@@ -13081,7 +13085,7 @@ int AddSession(WOLFSSL* ssl)
#ifdef SESSION_CERTS
if (error == 0) {
if (!overwrite || (overwrite && ssl->session.chain.count > 0)) {
if (!overwrite || ssl->session.chain.count > 0) {
/*
* If we are overwriting and no certs present in ssl->session.chain
* then keep the old chain.
@@ -14259,7 +14263,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
(void)sz;
WOLFSSL_MSG("session cache is set at compile time");
#ifndef NO_SESSION_CACHE
return SESSIONS_PER_ROW * SESSION_ROWS;
return (long)(SESSIONS_PER_ROW * SESSION_ROWS);
#else
return 0;
#endif
@@ -15282,7 +15286,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
int ret;
int hashType = WC_HASH_TYPE_NONE;
#ifdef WOLFSSL_SMALL_STACK
EncryptedInfo* info = NULL;
EncryptedInfo* info;
#else
EncryptedInfo info[1];
#endif
@@ -15417,7 +15421,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
do {
ret = wc_PeekErrorNode(0, &file, &reason, &line);
if (ret >= 0) {
const char* r = wolfSSL_ERR_reason_error_string(ret - ret - ret);
const char* r = wolfSSL_ERR_reason_error_string(0 - ret);
XSNPRINTF(buf, sizeof(buf), "error:%d:wolfSSL library:%s:%s:%d\n",
ret, r, file, line);
wolfSSL_BIO_write(bio, buf, (int)XSTRLEN(buf));
@@ -18184,7 +18188,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
{
(void)ctx;
#ifndef NO_SESSION_CACHE
return SESSIONS_PER_ROW * SESSION_ROWS;
return (long)(SESSIONS_PER_ROW * SESSION_ROWS);
#else
return 0;
#endif
@@ -18356,7 +18360,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
{
int ret;
#ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert = NULL;
DecodedCert* cert;
#else
DecodedCert cert[1];
#endif
@@ -18707,7 +18711,7 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
if (in != NULL && len != 0) {
#ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert = NULL;
DecodedCert* cert;
#else
DecodedCert cert[1];
#endif
@@ -19636,7 +19640,7 @@ WOLFSSL_STACK* wolfSSL_sk_get_node(WOLFSSL_STACK* sk, int idx)
{
int i;
WOLFSSL_STACK* ret = NULL;
WOLFSSL_STACK* current = NULL;
WOLFSSL_STACK* current;
current = sk;
for (i = 0; i <= idx && current != NULL; i++) {
@@ -20200,7 +20204,7 @@ WOLFSSL_X509* wolfSSL_X509_load_certificate_buffer(
/* ready to be decoded. */
if (der != NULL && der->buffer != NULL) {
#ifdef WOLFSSL_SMALL_STACK
DecodedCert* cert = NULL;
DecodedCert* cert;
#else
DecodedCert cert[1];
#endif
@@ -20336,7 +20340,7 @@ WOLFSSL_ASN1_OBJECT* wolfSSL_ASN1_OBJECT_new(void)
/* Creates and returns a new WOLFSSL_CIPHER stack. */
WOLFSSL_STACK* wolfSSL_sk_new_asn1_obj(void)
{
WOLFSSL_STACK* sk = NULL;
WOLFSSL_STACK* sk;
WOLFSSL_ENTER("wolfSSL_sk_new_asn1_obj");
sk = wolfSSL_sk_new_null();
@@ -22024,10 +22028,12 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b)
return WOLFSSL_FAILURE;
}
{
#if (!defined(NO_RSA) && !defined(HAVE_USER_RSA)) || defined(HAVE_ECC)
char tmp[100];
#endif
switch (x509->pubKeyOID) {
#ifndef NO_RSA
#ifndef NO_RSA
case RSAk:
if (wolfSSL_BIO_write(bio,
" Public Key Algorithm: rsaEncryption\n",
@@ -22167,9 +22173,9 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b)
}
#endif /* HAVE_USER_RSA */
break;
#endif /* NO_RSA */
#endif /* NO_RSA */
#ifdef HAVE_ECC
#ifdef HAVE_ECC
case ECDSAk:
{
word32 i;
@@ -22270,7 +22276,7 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b)
wc_ecc_free(&ecc);
}
break;
#endif /* HAVE_ECC */
#endif /* HAVE_ECC */
default:
WOLFSSL_MSG("Unknown key type");
return WOLFSSL_FAILURE;
@@ -24865,14 +24871,16 @@ int wolfSSL_X509_cmp_time(const WOLFSSL_ASN1_TIME* asnTime, time_t* cmpTime)
int ret = WOLFSSL_FAILURE, i = 0;
time_t tmpTime, *pTime = &tmpTime;
byte data_ptr[MAX_TIME_STRING_SZ], inv = 0;
struct tm ts, *tmpTs = NULL, *ct;
struct tm ts, *tmpTs, *ct;
#if defined(NEED_TMP_TIME)
/* for use with gmtime_r */
struct tm tmpTimeStorage;
tmpTs = &tmpTimeStorage;
#else
(void)tmpTs;
tmpTs = NULL;
#endif
(void)tmpTs;
if (asnTime == NULL) {
return WOLFSSL_FAILURE;
@@ -25224,16 +25232,17 @@ WOLFSSL_ASN1_TIME* wolfSSL_ASN1_TIME_adj(WOLFSSL_ASN1_TIME *s, time_t t,
{
const time_t sec_per_day = 24*60*60;
struct tm* ts = NULL;
struct tm* tmpTime = NULL;
struct tm* tmpTime;
time_t t_adj = 0;
time_t offset_day_sec = 0;
#if defined(NEED_TMP_TIME)
struct tm tmpTimeStorage;
tmpTime = &tmpTimeStorage;
#else
(void)tmpTime;
tmpTime = NULL;
#endif
(void)tmpTime;
WOLFSSL_ENTER("wolfSSL_ASN1_TIME_adj");
@@ -28710,7 +28719,7 @@ int wolfSSL_cmp_peer_cert_to_file(WOLFSSL* ssl, const char *fname)
#endif
byte* myBuffer = staticBuffer;
int dynamic = 0;
XFILE file = XBADFILE;
XFILE file;
long sz = 0;
WOLFSSL_CTX* ctx = ssl->ctx;
WOLFSSL_X509* peer_cert = &ssl->peerCert;
@@ -29124,7 +29133,7 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num)
int initTmpRng = 0;
WC_RNG* rng = NULL;
#ifdef WOLFSSL_SMALL_STACK
WC_RNG* tmpRNG = NULL;
WC_RNG* tmpRNG;
#else
WC_RNG tmpRNG[1];
#endif
@@ -29865,7 +29874,7 @@ int wolfSSL_DH_generate_key(WOLFSSL_DH* dh)
int initTmpRng = 0;
WC_RNG* rng = NULL;
#ifdef WOLFSSL_SMALL_STACK
WC_RNG* tmpRNG = NULL;
WC_RNG* tmpRNG;
#else
WC_RNG tmpRNG[1];
#endif
@@ -29876,7 +29885,6 @@ int wolfSSL_DH_generate_key(WOLFSSL_DH* dh)
#ifdef WOLFSSL_SMALL_STACK
tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_RNG);
if (tmpRNG == NULL) {
XFREE(tmpRNG, NULL, DYNAMIC_TYPE_RNG);
return ret;
@@ -29958,10 +29966,10 @@ int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* otherPub,
{
int ret = WOLFSSL_FATAL_ERROR;
word32 keySz = 0;
word32 pubSz = 1024;
word32 privSz = 1024;
int pubSz = 1024;
int privSz = 1024;
#ifdef WOLFSSL_SMALL_STACK
unsigned char* pub = NULL;
unsigned char* pub;
unsigned char* priv = NULL;
#else
unsigned char pub [1024];
@@ -30136,7 +30144,6 @@ void wolfSSL_DSA_free(WOLFSSL_DSA* dsa)
InitwolfSSL_DSA(dsa); /* set back to NULLs for safety */
XFREE(dsa, NULL, DYNAMIC_TYPE_DSA);
dsa = NULL;
}
}
@@ -30329,7 +30336,7 @@ int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA* rsa, int bits, WOLFSSL_BIGNUM* bn,
#ifdef WOLFSSL_KEY_GEN
{
#ifdef WOLFSSL_SMALL_STACK
WC_RNG* rng = NULL;
WC_RNG* rng;
#else
WC_RNG rng[1];
#endif
@@ -30393,7 +30400,7 @@ int wolfSSL_DSA_generate_key(WOLFSSL_DSA* dsa)
int initTmpRng = 0;
WC_RNG *rng = NULL;
#ifdef WOLFSSL_SMALL_STACK
WC_RNG *tmpRNG = NULL;
WC_RNG *tmpRNG;
#else
WC_RNG tmpRNG[1];
#endif
@@ -30494,7 +30501,7 @@ int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA* dsa, int bits,
int initTmpRng = 0;
WC_RNG *rng = NULL;
#ifdef WOLFSSL_SMALL_STACK
WC_RNG *tmpRNG = NULL;
WC_RNG *tmpRNG;
#else
WC_RNG tmpRNG[1];
#endif
@@ -30961,10 +30968,12 @@ int wolfSSL_HMAC_Init_ex(WOLFSSL_HMAC_CTX* ctx, const void* key,
* returns WOLFSSL_SUCCESS on success */
int wolfSSL_HmacCopy(Hmac* des, Hmac* src)
{
void* heap = NULL;
void* heap;
#ifndef HAVE_FIPS
heap = src->heap;
#else
heap = NULL;
#endif
if (wc_HmacInit(des, heap, 0) != 0) {
return WOLFSSL_FAILURE;
@@ -33315,7 +33324,6 @@ void wolfSSL_EC_KEY_free(WOLFSSL_EC_KEY *key)
InitwolfSSL_ECKey(key); /* set back to NULLs for safety */
XFREE(key, NULL, DYNAMIC_TYPE_ECC);
key = NULL;
}
}
#endif /* HAVE_ECC && (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */
@@ -33600,7 +33608,6 @@ void wolfSSL_EC_GROUP_free(WOLFSSL_EC_GROUP *group)
WOLFSSL_ENTER("wolfSSL_EC_GROUP_free");
XFREE(group, NULL, DYNAMIC_TYPE_ECC);
group = NULL;
}
#endif
@@ -34117,7 +34124,6 @@ void wolfSSL_EC_POINT_free(WOLFSSL_EC_POINT *p)
p->inSet = p->exSet = 0;
XFREE(p, NULL, DYNAMIC_TYPE_ECC);
p = NULL;
}
}
#endif
@@ -35512,7 +35518,7 @@ WOLFSSL_DSA *wolfSSL_PEM_read_bio_DSA_PUBKEY(WOLFSSL_BIO* bio,WOLFSSL_DSA** dsa,
WOLFSSL_EC_GROUP* wolfSSL_PEM_read_bio_ECPKParameters(WOLFSSL_BIO* bio,
WOLFSSL_EC_GROUP** group, pem_password_cb* cb, void* pass)
{
WOLFSSL_EVP_PKEY* pkey = NULL;
WOLFSSL_EVP_PKEY* pkey;
WOLFSSL_EC_GROUP* ret = NULL;
/* check on if bio is null is done in wolfSSL_PEM_read_bio_PrivateKey */
@@ -38395,7 +38401,7 @@ err:
WOLFSSL_X509_NAME_ENTRY* wolfSSL_X509_NAME_ENTRY_new(void)
{
WOLFSSL_X509_NAME_ENTRY* ne = NULL;
WOLFSSL_X509_NAME_ENTRY* ne;
ne = (WOLFSSL_X509_NAME_ENTRY*)XMALLOC(sizeof(WOLFSSL_X509_NAME_ENTRY),
NULL, DYNAMIC_TYPE_NAME_ENTRY);
@@ -38412,7 +38418,7 @@ err:
WOLFSSL_X509_NAME_ENTRY** out, int nid, int type,
const unsigned char* data, int dataSz)
{
WOLFSSL_X509_NAME_ENTRY* ne = NULL;
WOLFSSL_X509_NAME_ENTRY* ne;
WOLFSSL_ENTER("wolfSSL_X509_NAME_ENTRY_create_by_NID()");
@@ -39146,8 +39152,7 @@ err:
objSz += oidSz;
obj->objSz = objSz;
if(((obj->dynamic & WOLFSSL_ASN1_DYNAMIC_DATA) != 0) ||
(((obj->dynamic & WOLFSSL_ASN1_DYNAMIC_DATA) == 0) &&
(obj->obj == NULL))) {
(obj->obj == NULL)) {
obj->obj = (byte*)XREALLOC((byte*)obj->obj, obj->objSz, NULL,
DYNAMIC_TYPE_ASN1);
if (obj->obj == NULL) {
@@ -41758,7 +41763,7 @@ WOLFSSL_EVP_PKEY* wolfSSL_d2i_PrivateKey_bio(WOLFSSL_BIO* bio,
DYNAMIC_TYPE_TMP_BUFFER);
}
if (out != NULL && key != NULL) {
if (out != NULL) {
*out = key;
}
}
@@ -43487,14 +43492,13 @@ int wolfSSL_AsyncPoll(WOLFSSL* ssl, WOLF_EVENT_FLAG flags)
}
ret = wolfAsync_EventQueuePoll(&ssl->ctx->event_queue, ssl,
events, sizeof(events)/sizeof(events), flags, &eventCount);
events, sizeof(events)/sizeof(*events), flags, &eventCount);
if (ret == 0) {
ret = eventCount;
}
return ret;
}
#endif /* WOLFSSL_ASYNC_CRYPT */
#ifdef OPENSSL_EXTRA
@@ -46034,7 +46038,7 @@ int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM** bn, const char* str)
int ret = 0;
word32 decSz = 1024;
#ifdef WOLFSSL_SMALL_STACK
byte* decoded = NULL;
byte* decoded;
#else
byte decoded[1024];
#endif
@@ -46614,7 +46618,7 @@ const char *wolfSSL_ASN1_tag2str(int tag)
static int check_esc_char(char c, char *esc)
{
char *ptr = NULL;
char *ptr;
ptr = esc;
while(*ptr != 0){
@@ -46709,7 +46713,7 @@ int wolfSSL_ASN1_STRING_print_ex(WOLFSSL_BIO *out, WOLFSSL_ASN1_STRING *str,
if (flags & ASN1_STRFLGS_ESC_2253){
char esc_ch[] = "+;<>\\";
char* esc_ptr = NULL;
char* esc_ptr;
esc_ptr = str->data;
while (*esc_ptr != 0){
@@ -47186,7 +47190,6 @@ void wolfSSL_BN_free(WOLFSSL_BIGNUM* bn)
bn->internal = NULL;
}
XFREE(bn, NULL, DYNAMIC_TYPE_BIGINT);
bn = NULL;
}
}
@@ -47260,7 +47263,6 @@ void wolfSSL_RSA_free(WOLFSSL_RSA* rsa)
InitwolfSSL_Rsa(rsa); /* set back to NULLs for safety */
XFREE(rsa, NULL, DYNAMIC_TYPE_RSA);
rsa = NULL;
}
}
@@ -47296,7 +47298,7 @@ WOLFSSL_RSA* wolfSSL_RSA_new(void)
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && \
!defined(HAVE_FAST_RSA) && defined(WC_RSA_BLINDING)
{
WC_RNG* rng = NULL;
WC_RNG* rng;
rng = (WC_RNG*) XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_RNG);
if (rng != NULL && wc_InitRng(rng) != 0) {

View File

@@ -4811,7 +4811,7 @@ static int TLSX_SecureRenegotiation_Parse(WOLFSSL* ssl, byte* input,
int TLSX_UseSecureRenegotiation(TLSX** extensions, void* heap)
{
int ret = 0;
SecureRenegotiation* data = NULL;
SecureRenegotiation* data;
data = (SecureRenegotiation*)XMALLOC(sizeof(SecureRenegotiation), heap,
DYNAMIC_TYPE_TLSX);
@@ -5566,7 +5566,7 @@ static int TLSX_HaveQSHScheme(word16 name)
int TLSX_UseQSHScheme(TLSX** extensions, word16 name, byte* pKey, word16 pkeySz,
void* heap)
{
TLSX* extension = TLSX_Find(*extensions, TLSX_QUANTUM_SAFE_HYBRID);
TLSX* extension = NULL;
QSHScheme* format = NULL;
int ret = 0;
@@ -5579,6 +5579,7 @@ int TLSX_UseQSHScheme(TLSX** extensions, word16 name, byte* pKey, word16 pkeySz,
if ((ret = TLSX_QSH_Append(&format, name, pKey, pkeySz)) != 0)
return ret;
extension = TLSX_Find(*extensions, TLSX_QUANTUM_SAFE_HYBRID);
if (!extension) {
if ((ret = TLSX_Push(extensions, TLSX_QUANTUM_SAFE_HYBRID, format,
heap)) != 0) {

View File

@@ -1135,7 +1135,7 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
int i;
start += 13;
while (*start == ' ' && *start != '\0') start++;
while (*start == ' ') start++;
/* try and match against appStrList */
i = 0;
@@ -1154,13 +1154,13 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
}
else if (XSTRNCASECMP(start, "Content-Length:", 15) == 0) {
start += 15;
while (*start == ' ' && *start != '\0') start++;
while (*start == ' ') start++;
chunkSz = XATOI(start);
state = (state == phr_http_start) ? phr_have_length : phr_wait_end;
}
else if (XSTRNCASECMP(start, "Transfer-Encoding:", 18) == 0) {
start += 18;
while (*start == ' ' && *start != '\0') start++;
while (*start == ' ') start++;
if (XSTRNCASECMP(start, "chunked", 7) == 0) {
isChunked = 1;
state = (state == phr_http_start) ? phr_have_length : phr_wait_end;
@@ -2012,7 +2012,7 @@ void mynewt_ctx_clear(void *ctx) {
/* return Mynewt_Ctx instance */
void* mynewt_ctx_new() {
int rc = 0;
Mynewt_Ctx *mynewt_ctx = NULL;
Mynewt_Ctx *mynewt_ctx;
int mem_buf_count = MYNEWT_VAL(WOLFSSL_MNSOCK_MEM_BUF_COUNT);
int mem_buf_size = MYNEWT_VAL(WOLFSSL_MNSOCK_MEM_BUF_SIZE);
int mempool_bytes = OS_MEMPOOL_BYTES(mem_buf_count, mem_buf_size);
@@ -2149,7 +2149,7 @@ int Mynewt_Send(WOLFSSL* ssl, char *buf, int sz, void *ctx)
{
Mynewt_Ctx *mynewt_ctx = (Mynewt_Ctx*)ctx;
int rc = 0;
struct os_mbuf *m = NULL;
struct os_mbuf *m;
int write_sz = 0;
m = os_msys_get_pkthdr(sz, 0);
if (!m) {