From 75c1a6f97c9b25b71bcc95b158bc673f6db04400 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Mon, 19 Aug 2013 14:25:29 +0200 Subject: [PATCH] Fixed potential heap buffer overflow on large hostname setting --- library/ssl_tls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index e2bc3da12..9c1e53a4c 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3220,6 +3220,10 @@ int ssl_set_hostname( ssl_context *ssl, const char *hostname ) return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); ssl->hostname_len = strlen( hostname ); + + if( ssl->hostname_len + 1 == 0 ) + return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); + ssl->hostname = (unsigned char *) polarssl_malloc( ssl->hostname_len + 1 ); if( ssl->hostname == NULL )