From 357b0b283a81b7283116f1199da0e2bc459daad4 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Sun, 29 Apr 2018 22:04:03 +0100 Subject: [PATCH] Fix ret code in ssl_cert_test.c --- programs/test/ssl_cert_test.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/programs/test/ssl_cert_test.c b/programs/test/ssl_cert_test.c index 9cfcd2d554..7e5ed384b2 100644 --- a/programs/test/ssl_cert_test.c +++ b/programs/test/ssl_cert_test.c @@ -29,9 +29,12 @@ #include "mbedtls/platform.h" #else #include -#define mbedtls_snprintf snprintf -#define mbedtls_printf printf -#endif +#include +#define mbedtls_snprintf snprintf +#define mbedtls_printf printf +#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif /* MBEDTLS_PLATFORM_C */ #if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_X509_CRT_PARSE_C) && \ defined(MBEDTLS_FS_IO) && defined(MBEDTLS_X509_CRL_PARSE_C) @@ -80,7 +83,8 @@ const char *client_private_keys[MAX_CLIENT_CERTS] = int main( void ) { - int ret, i; + int ret = 1, i; + int exit_code = MBEDTLS_EXIT_FAILURE; mbedtls_x509_crt cacert; mbedtls_x509_crl crl; char buf[10240]; @@ -210,7 +214,6 @@ int main( void ) if( ! mbedtls_pk_can_do( &clicert.pk, MBEDTLS_PK_RSA ) ) { mbedtls_printf( " failed\n ! certificate's key is not RSA\n\n" ); - ret = MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE; goto exit; } @@ -241,6 +244,8 @@ int main( void ) mbedtls_pk_free( &pk ); } + exit_code = MBEDTLS_EXIT_SUCCESS; + exit: mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crl_free( &crl ); @@ -250,7 +255,7 @@ exit: fflush( stdout ); getchar(); #endif - return( ret ); + return( exit_code ); } #endif /* MBEDTLS_RSA_C && MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_FS_IO && MBEDTLS_X509_CRL_PARSE_C */