Skip to content

Commit 7de150e

Browse files
Merge pull request #9975 from rlm2002/coverity
20260313 Coverity changes
2 parents 30d8cf1 + 2ca2781 commit 7de150e

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

examples/ocsp_responder/ocsp_responder.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ static int LoadFile(const char* filename, byte** buf, word32* bufSz, int* isPem)
177177

178178
/* Check if PEM format by looking for -----BEGIN */
179179
if (isPem) {
180+
/* Reallocate with space for null terminator for XSTRSTR */
181+
byte* tmp = (byte*)XREALLOC(*buf, (word32)sz + 1, NULL,
182+
DYNAMIC_TYPE_TMP_BUFFER);
183+
if (tmp == NULL) {
184+
XFREE(*buf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
185+
*buf = NULL;
186+
return MEMORY_E;
187+
}
188+
*buf = tmp;
189+
(*buf)[sz] = '\0';
180190
*isPem = (XSTRSTR((char*)*buf, "-----BEGIN") != NULL) ? 1 : 0;
181191
}
182192

@@ -749,6 +759,9 @@ THREAD_RETURN WOLFSSL_THREAD ocsp_responder_test(void* args)
749759
opts.sendCerts = 1;
750760
opts.readyFile = NULL;
751761

762+
/* Initialize caCert */
763+
XMEMSET(&caCert, 0, sizeof(caCert));
764+
752765
/* Parse command line arguments */
753766
while ((ch = mygetopt_long(argc, argv, "?p:c:r:k:i:R:n:vx",
754767
long_options, 0)) != -1) {
@@ -848,7 +861,6 @@ THREAD_RETURN WOLFSSL_THREAD ocsp_responder_test(void* args)
848861
}
849862

850863
/* Parse CA certificate to get subject */
851-
XMEMSET(&caCert, 0, sizeof(caCert));
852864
wc_InitDecodedCert(&caCert, caCertDer, caCertDerSz, NULL);
853865
ret = wc_ParseCert(&caCert, CERT_TYPE, 0, NULL);
854866
if (ret != 0) {

src/ssl_api_pk.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ static int check_cert_key(const DerBuffer* cert, const DerBuffer* key,
226226
InitDecodedCert_ex(der, cert->buffer, cert->length, heap, devId);
227227
/* Parse certificate. */
228228
if (ParseCertRelative(der, CERT_TYPE, NO_VERIFY, NULL, NULL) != 0) {
229-
WC_FREE_VAR_EX(der, heap, DYNAMIC_TYPE_DCERT);
230229
ret = 0;
231230
}
232231
}

wolfcrypt/src/asn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18027,10 +18027,13 @@ static word32 SetAlgoIDImpl(int algoOID, byte* output, int type, int curveSz,
1802718027
word32 algoSz = 0;
1802818028

1802918029
CALLOC_ASNSETDATA(dataASN, algoIdASN_Length, ret, NULL);
18030+
18031+
#ifdef WOLFSSL_SMALL_STACK
1803018032
if(ret < 0) {
1803118033
/* Catch MEMORY_E */
1803218034
return 0;
1803318035
}
18036+
#endif
1803418037

1803518038
algoName = OidFromId((word32)algoOID, (word32)type, &algoSz);
1803618039
if (algoName == NULL) {

0 commit comments

Comments
 (0)