Fixed undefined behavior in ssl_read if buf parameter is NULL.

Signed-off-by: Ashley Duncan <[email protected]>
This commit is contained in:
Ashley Duncan
2023-02-24 16:02:25 +00:00
committed by Dave Rodgman
parent 4dcc08c244
commit 272cc19ab5
+4 -2
View File
@@ -5429,8 +5429,10 @@ int mbedtls_ssl_read(mbedtls_ssl_context *ssl, unsigned char *buf, size_t len)
n = (len < ssl->in_msglen)
? len : ssl->in_msglen;
memcpy(buf, ssl->in_offt, n);
ssl->in_msglen -= n;
if (buf) {
memcpy(buf, ssl->in_offt, n);
ssl->in_msglen -= n;
}
/* Zeroising the plaintext buffer to erase unused application data
from the memory. */