Skip to content

Commit 5c4922c

Browse files
committed
zero-initialize DecodedCert immediately after allocation in
wolfssl_certmanagerloadcabuffertype to prevent cleanup on an uninitialized struct on the pem error path.
1 parent 7d1516f commit 5c4922c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/ssl_certman.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ int wolfSSL_CertManagerLoadCABufferType(WOLFSSL_CERT_MANAGER* cm,
633633
if (dCert == NULL) {
634634
ret = WOLFSSL_FATAL_ERROR;
635635
} else {
636+
XMEMSET(dCert, 0, sizeof(DecodedCert));
636637
if (format == WOLFSSL_FILETYPE_PEM) {
637638
#ifndef WOLFSSL_PEM_TO_DER
638639
ret = NOT_COMPILED_IN;
@@ -651,7 +652,6 @@ int wolfSSL_CertManagerLoadCABufferType(WOLFSSL_CERT_MANAGER* cm,
651652
}
652653

653654
if (ret == WOLFSSL_SUCCESS) {
654-
XMEMSET(dCert, 0, sizeof(DecodedCert));
655655
wc_InitDecodedCert(dCert, buff,
656656
(word32)sz, cm->heap);
657657
ret = wc_ParseCert(dCert, CERT_TYPE, NO_VERIFY, NULL);

0 commit comments

Comments
 (0)