[PATCH 3/5] wpa_supplicant: Fix possible memory leak in openssl_tls_prf()

Ilan Peer ilan.peer
Wed Jun 17 06:16:34 PDT 2015


From: Ben Rosenfeld <ben.rosenfeld at intel.com>

Free tmp_out before returning to prevent memory leak.

Signed-off-by: Ben Rosenfeld <ben.rosenfeld at intel.com>
---
 src/crypto/tls_openssl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/crypto/tls_openssl.c b/src/crypto/tls_openssl.c
index db3bc5b..507a12e 100644
--- a/src/crypto/tls_openssl.c
+++ b/src/crypto/tls_openssl.c
@@ -2747,8 +2747,11 @@ static int openssl_tls_prf(void *tls_ctx, struct tls_connection *conn,
 	}
 
 	rnd = os_malloc(2 * SSL3_RANDOM_SIZE);
-	if (rnd == NULL)
+	if (!rnd) {
+		os_free(tmp_out);
 		return -1;
+	}
+
 	if (server_random_first) {
 		os_memcpy(rnd, ssl->s3->server_random, SSL3_RANDOM_SIZE);
 		os_memcpy(rnd + SSL3_RANDOM_SIZE, ssl->s3->client_random,
-- 
1.9.1




More information about the Hostap mailing list