From 216b40de9b5b9cf820a783d8886db78108bffd7d Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Wed, 20 Jun 2018 07:07:55 -0400 Subject: [PATCH] ssl_server2: add buffer overhead for a termination character Switch to mbedtls style of memory allocation --- programs/ssl/ssl_server2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 1a57a7994..6736bcc4a 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1355,7 +1355,7 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_DEBUG_C) mbedtls_debug_set_threshold( opt.debug_level ); #endif - buf = malloc( opt.buffer_size ); + buf = mbedtls_calloc( 1, opt.buffer_size + 1 ); if( buf == NULL ) { mbedtls_printf("Could not allocate %u bytes\n", opt.buffer_size); @@ -2545,6 +2545,7 @@ exit: mbedtls_memory_buffer_alloc_free(); #endif + mbedtls_free(buf); mbedtls_printf( " done.\n" ); #if defined(_WIN32)