Fix out of bound memset to 0

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 <nunojpg@gmail.com>
This commit is contained in:
Nuno Gonçalves
2023-02-18 10:38:02 +00:00
parent 6cc5c1a428
commit 4e6bad1225

View File

@ -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);
}