Fix ret code in dh_genprime.c

This commit is contained in:
Andres Amaya Garcia 2018-04-29 19:34:09 +01:00 committed by Simon Butcher
parent f842345ac3
commit 74c51e6e64

View File

@ -30,9 +30,11 @@
#else
#include <stdio.h>
#include <stdlib.h>
#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 */