Merge pull request #7616 from embhorn/zd17762

Static analysis fixes
This commit is contained in:
Daniel Pouzzner
2024-06-12 17:07:02 -04:00
committed by GitHub

View File

@ -7053,7 +7053,7 @@ void FreeHandshakeHashes(WOLFSSL* ssl)
int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source, int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
HS_Hashes** destination) HS_Hashes** destination)
{ {
int ret = 0; int ret;
HS_Hashes* tmpHashes; HS_Hashes* tmpHashes;
if (source == NULL) if (source == NULL)
@ -7063,7 +7063,11 @@ int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
tmpHashes = ssl->hsHashes; tmpHashes = ssl->hsHashes;
ssl->hsHashes = NULL; ssl->hsHashes = NULL;
InitHandshakeHashes(ssl); ret = InitHandshakeHashes(ssl);
if (ret != 0) {
WOLFSSL_MSG_EX("InitHandshakeHashes failed. err = %d", ret);
return ret;
}
*destination = ssl->hsHashes; *destination = ssl->hsHashes;
ssl->hsHashes = tmpHashes; ssl->hsHashes = tmpHashes;
@ -7071,50 +7075,50 @@ int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
/* now copy the source contents to the destination */ /* now copy the source contents to the destination */
#ifndef NO_OLD_TLS #ifndef NO_OLD_TLS
#ifndef NO_SHA #ifndef NO_SHA
ret = wc_ShaCopy(&source->hashSha, &(*destination)->hashSha); ret = wc_ShaCopy(&source->hashSha, &(*destination)->hashSha);
#endif #endif
#ifndef NO_MD5 #ifndef NO_MD5
if (ret == 0) if (ret == 0)
ret = wc_Md5Copy(&source->hashMd5, &(*destination)->hashMd5); ret = wc_Md5Copy(&source->hashMd5, &(*destination)->hashMd5);
#endif #endif
#endif /* !NO_OLD_TLS */ #endif /* !NO_OLD_TLS */
#ifndef NO_SHA256 #ifndef NO_SHA256
if (ret == 0) if (ret == 0)
ret = wc_Sha256Copy(&source->hashSha256, ret = wc_Sha256Copy(&source->hashSha256,
&(*destination)->hashSha256); &(*destination)->hashSha256);
#endif #endif
#ifdef WOLFSSL_SHA384 #ifdef WOLFSSL_SHA384
if (ret == 0) if (ret == 0)
ret = wc_Sha384Copy(&source->hashSha384, ret = wc_Sha384Copy(&source->hashSha384,
&(*destination)->hashSha384); &(*destination)->hashSha384);
#endif #endif
#ifdef WOLFSSL_SHA512 #ifdef WOLFSSL_SHA512
if (ret == 0) if (ret == 0)
ret = wc_Sha512Copy(&source->hashSha512, ret = wc_Sha512Copy(&source->hashSha512,
&(*destination)->hashSha512); &(*destination)->hashSha512);
#endif #endif
#ifdef WOLFSSL_SM3 #ifdef WOLFSSL_SM3
if (ret == 0) if (ret == 0)
ret = wc_Sm3Copy(&source->hashSm3, ret = wc_Sm3Copy(&source->hashSm3,
&(*destination)->hashSm3); &(*destination)->hashSm3);
#endif #endif
#if (defined(HAVE_ED25519) || defined(HAVE_ED448) || \ #if (defined(HAVE_ED25519) || defined(HAVE_ED448) || \
(defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3))) && \ (defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3))) && \
!defined(WOLFSSL_NO_CLIENT_AUTH) !defined(WOLFSSL_NO_CLIENT_AUTH)
if (ret == 0 && source->messages != NULL) { if (ret == 0 && source->messages != NULL) {
(*destination)->messages = (byte*)XMALLOC(source->length, ssl->heap, (*destination)->messages = (byte*)XMALLOC(source->length, ssl->heap,
DYNAMIC_TYPE_HASHES); DYNAMIC_TYPE_HASHES);
(*destination)->length = source->length; (*destination)->length = source->length;
(*destination)->prevLen = source->prevLen; (*destination)->prevLen = source->prevLen;
if ((*destination)->messages == NULL) { if ((*destination)->messages == NULL) {
ret = MEMORY_E; ret = MEMORY_E;
}
else {
XMEMCPY((*destination)->messages, source->messages,
source->length);
}
} }
else {
XMEMCPY((*destination)->messages, source->messages,
source->length);
}
}
#endif #endif
return ret; return ret;