From 4bb6c51d2d553c94d53216366c954c0e1d2a87f0 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Thu, 5 Oct 2023 14:20:37 -0600 Subject: [PATCH] Fix -4 return code when expected BAD_FUNC_ARG(-173) --- src/ssl_certman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ssl_certman.c b/src/ssl_certman.c index d261c0272..9f227be15 100644 --- a/src/ssl_certman.c +++ b/src/ssl_certman.c @@ -819,7 +819,11 @@ int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER* cm, const char* fname, WOLFSSL_MSG("Getting dynamic buffer"); buff = (byte*)XMALLOC((size_t)sz, cm->heap, DYNAMIC_TYPE_FILE); if (buff == NULL) { - ret = WOLFSSL_BAD_FILE; + /* If some other error has already occurred preserve that code + * return WOLFSSL_BAD_FILE if that is the only error condition */ + if (ret == WOLFSSL_SUCCESS) { + ret = WOLFSSL_BAD_FILE; + } } } /* Read all the file into buffer. */