Skip to content

Commit d2f4cc9

Browse files
authored
Merge pull request #7616 from embhorn/zd17762
Static analysis fixes
2 parents b0d0a1a + 55837fa commit d2f4cc9

1 file changed

Lines changed: 33 additions & 29 deletions

File tree

src/internal.c

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7053,7 +7053,7 @@ void FreeHandshakeHashes(WOLFSSL* ssl)
70537053
int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
70547054
HS_Hashes** destination)
70557055
{
7056-
int ret = 0;
7056+
int ret;
70577057
HS_Hashes* tmpHashes;
70587058

70597059
if (source == NULL)
@@ -7063,58 +7063,62 @@ int InitHandshakeHashesAndCopy(WOLFSSL* ssl, HS_Hashes* source,
70637063
tmpHashes = ssl->hsHashes;
70647064
ssl->hsHashes = NULL;
70657065

7066-
InitHandshakeHashes(ssl);
7066+
ret = InitHandshakeHashes(ssl);
7067+
if (ret != 0) {
7068+
WOLFSSL_MSG_EX("InitHandshakeHashes failed. err = %d", ret);
7069+
return ret;
7070+
}
70677071

70687072
*destination = ssl->hsHashes;
70697073
ssl->hsHashes = tmpHashes;
70707074

70717075
/* now copy the source contents to the destination */
70727076
#ifndef NO_OLD_TLS
70737077
#ifndef NO_SHA
7074-
ret = wc_ShaCopy(&source->hashSha, &(*destination)->hashSha);
7078+
ret = wc_ShaCopy(&source->hashSha, &(*destination)->hashSha);
70757079
#endif
70767080
#ifndef NO_MD5
7077-
if (ret == 0)
7078-
ret = wc_Md5Copy(&source->hashMd5, &(*destination)->hashMd5);
7081+
if (ret == 0)
7082+
ret = wc_Md5Copy(&source->hashMd5, &(*destination)->hashMd5);
70797083
#endif
70807084
#endif /* !NO_OLD_TLS */
70817085
#ifndef NO_SHA256
7082-
if (ret == 0)
7083-
ret = wc_Sha256Copy(&source->hashSha256,
7084-
&(*destination)->hashSha256);
7086+
if (ret == 0)
7087+
ret = wc_Sha256Copy(&source->hashSha256,
7088+
&(*destination)->hashSha256);
70857089
#endif
70867090
#ifdef WOLFSSL_SHA384
7087-
if (ret == 0)
7088-
ret = wc_Sha384Copy(&source->hashSha384,
7089-
&(*destination)->hashSha384);
7091+
if (ret == 0)
7092+
ret = wc_Sha384Copy(&source->hashSha384,
7093+
&(*destination)->hashSha384);
70907094
#endif
70917095
#ifdef WOLFSSL_SHA512
7092-
if (ret == 0)
7093-
ret = wc_Sha512Copy(&source->hashSha512,
7094-
&(*destination)->hashSha512);
7096+
if (ret == 0)
7097+
ret = wc_Sha512Copy(&source->hashSha512,
7098+
&(*destination)->hashSha512);
70957099
#endif
70967100
#ifdef WOLFSSL_SM3
7097-
if (ret == 0)
7098-
ret = wc_Sm3Copy(&source->hashSm3,
7099-
&(*destination)->hashSm3);
7101+
if (ret == 0)
7102+
ret = wc_Sm3Copy(&source->hashSm3,
7103+
&(*destination)->hashSm3);
71007104
#endif
71017105
#if (defined(HAVE_ED25519) || defined(HAVE_ED448) || \
71027106
(defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3))) && \
71037107
!defined(WOLFSSL_NO_CLIENT_AUTH)
7104-
if (ret == 0 && source->messages != NULL) {
7105-
(*destination)->messages = (byte*)XMALLOC(source->length, ssl->heap,
7106-
DYNAMIC_TYPE_HASHES);
7107-
(*destination)->length = source->length;
7108-
(*destination)->prevLen = source->prevLen;
7108+
if (ret == 0 && source->messages != NULL) {
7109+
(*destination)->messages = (byte*)XMALLOC(source->length, ssl->heap,
7110+
DYNAMIC_TYPE_HASHES);
7111+
(*destination)->length = source->length;
7112+
(*destination)->prevLen = source->prevLen;
71097113

7110-
if ((*destination)->messages == NULL) {
7111-
ret = MEMORY_E;
7112-
}
7113-
else {
7114-
XMEMCPY((*destination)->messages, source->messages,
7115-
source->length);
7116-
}
7114+
if ((*destination)->messages == NULL) {
7115+
ret = MEMORY_E;
71177116
}
7117+
else {
7118+
XMEMCPY((*destination)->messages, source->messages,
7119+
source->length);
7120+
}
7121+
}
71187122
#endif
71197123

71207124
return ret;

0 commit comments

Comments
 (0)