From d81a08a03b6f1644dec0837eef53ffe7c3d1bac0 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Mon, 4 Mar 2024 09:48:31 -0500 Subject: [PATCH] Catch error return code and remove redundant condition --- src/x509.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/x509.c b/src/x509.c index 05c3a02d4..eefa69cb2 100644 --- a/src/x509.c +++ b/src/x509.c @@ -1545,22 +1545,10 @@ int wolfSSL_X509V3_EXT_print(WOLFSSL_BIO *out, WOLFSSL_X509_EXTENSION *ext, WOLFSSL_MSG("Memory error"); return rc; } - if (sk->next) { - if ((valLen = XSNPRINTF(val, len, "%*s%s,", - indent, "", str->strData)) - >= len) { - XFREE(val, NULL, DYNAMIC_TYPE_TMP_BUFFER); - return rc; - } - } else { - if ((valLen = XSNPRINTF(val, len, "%*s%s", - indent, "", str->strData)) - >= len) { - XFREE(val, NULL, DYNAMIC_TYPE_TMP_BUFFER); - return rc; - } - } - if ((tmpLen + valLen) >= tmpSz) { + valLen = XSNPRINTF(val, len, "%*s%s", indent, "", + str->strData); + if ((valLen < 0) || (valLen >= len) + || ((tmpLen + valLen) >= tmpSz)) { XFREE(val, NULL, DYNAMIC_TYPE_TMP_BUFFER); return rc; }