From 4e6bad1225a0623b9f8f413967a601ff885eaf07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Gon=C3=A7alves?= Date: Sat, 18 Feb 2023 10:38:02 +0000 Subject: [PATCH] Fix out of bound memset to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case buf size sz is too small it will get updated to the larger required value and can't be used anymore to clear the buffer. As the buffer is untouched don't need to clear it anyway. Signed-off-by: Nuno Gonçalves --- src/internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index 0ea69109c..6e29d8bf5 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2030,7 +2030,7 @@ int wolfSSL_session_export_internal(WOLFSSL* ssl, byte* buf, word32* sz, } } - if (ret != 0 && buf != NULL) { + if (ret != 0 && ret != LENGTH_ONLY_E && buf != NULL) { /*in a fail case clear the buffer which could contain partial key info*/ XMEMSET(buf, 0, *sz); }