From 74c51e6e6433eeed0404a26791dc44bf26ae03dd Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Sun, 29 Apr 2018 19:34:09 +0100 Subject: [PATCH] Fix ret code in dh_genprime.c --- programs/pkey/dh_genprime.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/programs/pkey/dh_genprime.c b/programs/pkey/dh_genprime.c index 84a94a18b..7884ea668 100644 --- a/programs/pkey/dh_genprime.c +++ b/programs/pkey/dh_genprime.c @@ -30,9 +30,11 @@ #else #include #include -#define mbedtls_printf printf -#define mbedtls_time_t time_t -#endif +#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_BIGNUM_C) || !defined(MBEDTLS_ENTROPY_C) || \ !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C) || \ @@ -69,6 +71,7 @@ int main( void ) int main( int argc, char **argv ) { int ret = 1; + int exit_code = MBEDTLS_EXIT_FAILURE; mbedtls_mpi G, P, Q; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; @@ -86,7 +89,7 @@ int main( int argc, char **argv ) { usage: mbedtls_printf( USAGE ); - return( 1 ); + return( exit_code ); } for( i = 1; i < argc; i++ ) @@ -164,7 +167,6 @@ int main( int argc, char **argv ) if( ( fout = fopen( "dh_prime.txt", "wb+" ) ) == NULL ) { - ret = 1; mbedtls_printf( " failed\n ! Could not create dh_prime.txt\n\n" ); goto exit; } @@ -180,6 +182,8 @@ int main( int argc, char **argv ) mbedtls_printf( " ok\n\n" ); fclose( fout ); + exit_code = MBEDTLS_EXIT_SUCCESS; + exit: mbedtls_mpi_free( &G ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q ); @@ -191,7 +195,7 @@ exit: fflush( stdout ); getchar(); #endif - return( ret ); + return( exit_code ); } #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C && MBEDTLS_GENPRIME */