From 114ba1955eb7496a1f824682a82d55b37d6204c5 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Sun, 29 Apr 2018 19:40:45 +0100 Subject: [PATCH] Fix ret code in dh_server.c --- programs/pkey/dh_server.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c index 430423154..d7765e332 100644 --- a/programs/pkey/dh_server.c +++ b/programs/pkey/dh_server.c @@ -29,9 +29,12 @@ #include "mbedtls/platform.h" #else #include -#define mbedtls_printf printf -#define mbedtls_time_t time_t -#endif +#include +#define mbedtls_printf printf +#define mbedtls_time_t time_t +#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif /* MBEDTLS_PLATFORM_C */ #if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \ defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \ @@ -71,7 +74,8 @@ int main( void ) { FILE *f; - int ret; + int ret = 1; + int exit_code = MBEDTLS_EXIT_FAILURE; size_t n, buflen; mbedtls_net_context listen_fd, client_fd; @@ -121,7 +125,6 @@ int main( void ) if( ( f = fopen( "rsa_priv.txt", "rb" ) ) == NULL ) { - ret = 1; mbedtls_printf( " failed\n ! Could not open rsa_priv.txt\n" \ " ! Please run rsa_genkey first\n\n" ); goto exit; @@ -164,7 +167,6 @@ int main( void ) if( ( f = fopen( "dh_prime.txt", "rb" ) ) == NULL ) { - ret = 1; mbedtls_printf( " failed\n ! Could not open dh_prime.txt\n" \ " ! Please run dh_genprime first\n\n" ); goto exit; @@ -304,6 +306,8 @@ int main( void ) mbedtls_printf( "\n\n" ); + exit_code = MBEDTLS_EXIT_SUCCESS; + exit: mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q ); @@ -323,7 +327,7 @@ exit: fflush( stdout ); getchar(); #endif - return( ret ); + return( exit_code ); } #endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&