From 2d0a5840feaa66eec65582bf39ebc864316d2487 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Thu, 6 Jul 2017 14:07:53 +0100 Subject: [PATCH] Fix MSVC warning in sample programs The warning was caused because of conversions from size_t to int, which can cause data loss. The files affected are: * ssl_client2.c * ssl_server2.c * ssl_mail_client.c --- programs/ssl/ssl_client2.c | 2 +- programs/ssl/ssl_mail_client.c | 4 ++-- programs/ssl/ssl_server2.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 1856cc45f..af3b0d35d 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1267,7 +1267,7 @@ send_request: len = polarssl_snprintf( (char *) buf, sizeof(buf) - 1, GET_REQUEST, opt.request_page ); - tail_len = strlen( GET_REQUEST_END ); + tail_len = (int) strlen( GET_REQUEST_END ); /* Add padding to GET request to reach opt.request_size in length */ if( opt.request_size != DFL_REQUEST_SIZE && diff --git a/programs/ssl/ssl_mail_client.c b/programs/ssl/ssl_mail_client.c index 27c57a17f..8958f18f7 100644 --- a/programs/ssl/ssl_mail_client.c +++ b/programs/ssl/ssl_mail_client.c @@ -57,8 +57,8 @@ #include #else #include -#define read _read -#define write _write +#define read(fd, buf, len) _read( fd, (void *)buf, (unsigned int)len ) +#define write(fd, buf, len) _write( fd, (const void *)buf, (unsigned int)len ) #endif #if defined(_WIN32) || defined(_WIN32_WCE) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 5b4d634d3..b99aeb6a0 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1791,7 +1791,7 @@ data_exchange: unsigned char *larger_buf; ori_len = ret; - extra_len = ssl_get_bytes_avail( &ssl ); + extra_len = (int) ssl_get_bytes_avail( &ssl ); larger_buf = polarssl_malloc( ori_len + extra_len + 1 ); if( larger_buf == NULL )