From 0a860f63013152cf995370f594eff0da9131e033 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Sun, 29 Apr 2018 20:27:09 +0100 Subject: [PATCH] Fix ret code in rsa_verify.c --- programs/pkey/rsa_verify.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/programs/pkey/rsa_verify.c b/programs/pkey/rsa_verify.c index 1f827aa07..5625abacf 100644 --- a/programs/pkey/rsa_verify.c +++ b/programs/pkey/rsa_verify.c @@ -29,9 +29,12 @@ #include "mbedtls/platform.h" #else #include -#define mbedtls_printf printf -#define mbedtls_snprintf snprintf -#endif +#include +#define mbedtls_printf printf +#define mbedtls_snprintf snprintf +#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif /* MBEDTLS_PLATFORM_C */ #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \ !defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \ @@ -54,7 +57,8 @@ int main( void ) int main( int argc, char *argv[] ) { FILE *f; - int ret, c; + int ret = 1, c; + int exit_code = MBEDTLS_EXIT_FAILURE; size_t i; mbedtls_rsa_context rsa; unsigned char hash[32]; @@ -62,7 +66,6 @@ int main( int argc, char *argv[] ) char filename[512]; mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 ); - ret = 1; if( argc != 2 ) { @@ -100,7 +103,6 @@ int main( int argc, char *argv[] ) /* * Extract the RSA signature from the text file */ - ret = 1; mbedtls_snprintf( filename, sizeof(filename), "%s.sig", argv[1] ); if( ( f = fopen( filename, "rb" ) ) == NULL ) @@ -146,7 +148,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( "\n . OK (the signature is valid)\n\n" ); - ret = 0; + exit_code = MBEDTLS_EXIT_SUCCESS; exit: @@ -157,7 +159,7 @@ exit: fflush( stdout ); getchar(); #endif - return( ret ); + return( exit_code ); } #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && MBEDTLS_FS_IO */