Fix ret code in cert_req.c

This commit is contained in:
Andres Amaya Garcia 2018-04-29 21:36:13 +01:00 committed by Simon Butcher
parent ea14fe76d5
commit 7bd88dc44c

View File

@ -29,8 +29,11 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#endif #define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */
#if !defined(MBEDTLS_X509_CSR_WRITE_C) || !defined(MBEDTLS_FS_IO) || \ #if !defined(MBEDTLS_X509_CSR_WRITE_C) || !defined(MBEDTLS_FS_IO) || \
!defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_SHA256_C) || \ !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_SHA256_C) || \
@ -133,7 +136,8 @@ int write_certificate_request( mbedtls_x509write_csr *req, const char *output_fi
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
int ret = 0; int ret = 1;
int exit_code = MBEDTLS_EXIT_FAILURE;
mbedtls_pk_context key; mbedtls_pk_context key;
char buf[1024]; char buf[1024];
int i; int i;
@ -156,7 +160,6 @@ int main( int argc, char *argv[] )
{ {
usage: usage:
mbedtls_printf( USAGE ); mbedtls_printf( USAGE );
ret = 1;
goto exit; goto exit;
} }
@ -317,9 +320,11 @@ int main( int argc, char *argv[] )
mbedtls_printf( " ok\n" ); mbedtls_printf( " ok\n" );
exit_code = MBEDTLS_EXIT_SUCCESS;
exit: exit:
if( ret != 0 && ret != 1) if( exit_code != MBEDTLS_EXIT_SUCCESS )
{ {
#ifdef MBEDTLS_ERROR_C #ifdef MBEDTLS_ERROR_C
mbedtls_strerror( ret, buf, sizeof( buf ) ); mbedtls_strerror( ret, buf, sizeof( buf ) );
@ -339,7 +344,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( ret ); return( exit_code );
} }
#endif /* MBEDTLS_X509_CSR_WRITE_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && #endif /* MBEDTLS_X509_CSR_WRITE_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&
MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_WRITE_C */ MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_WRITE_C */