From ef52796537c89bfb06d4eb5daecab7d013a57749 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Thu, 15 Mar 2018 15:49:24 +0000 Subject: [PATCH] Fix missing return statement ssl_server2 idling Also, introduce MBEDTLS_EINTR locally in net_sockets.c for the platform-dependent return code macro used by the `select` call to indicate that the poll was interrupted by a signal handler: On Unix, the corresponding macro is EINTR, while on Windows, it's WSAEINTR. --- library/net_sockets.c | 11 +++++------ programs/ssl/ssl_client2.c | 2 +- programs/ssl/ssl_server2.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/library/net_sockets.c b/library/net_sockets.c index 96cfa35cd..10b5456be 100644 --- a/library/net_sockets.c +++ b/library/net_sockets.c @@ -45,6 +45,8 @@ #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ !defined(EFI32) +#define MBEDTLS_EINTR WSAEINTR + #ifdef _WIN32_WINNT #undef _WIN32_WINNT #endif @@ -82,6 +84,8 @@ static int wsa_init_done = 0; #include #include +#define MBEDTLS_EINTR EINTR + #endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ /* Some MS functions want int and MSVC warns if we pass size_t, @@ -475,12 +479,7 @@ int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout ) ret = select( fd + 1, &read_fds, &write_fds, NULL, timeout == (uint32_t) -1 ? NULL : &tv ); } -#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ - !defined(EFI32) - while( ret == WSAEINTR ); -#else - while( ret == EINTR ); -#endif + while( ret == MBEDTLS_EINTR ); if( ret < 0 ) return( MBEDTLS_ERR_NET_POLL_FAILED ); diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 232dc6445..58f12c986 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -462,7 +462,7 @@ int idle( mbedtls_net_context *fd, poll_type = MBEDTLS_NET_POLL_READ; #if !defined(MBEDTLS_TIMING_C) else - return; + return( 0 ); #endif while( 1 ) diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 3a6b9dcf1..ed38a321b 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -863,7 +863,7 @@ int idle( mbedtls_net_context *fd, poll_type = MBEDTLS_NET_POLL_READ; #if !defined(MBEDTLS_TIMING_C) else - return; + return( 0 ); #endif while( 1 )