1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Ensure MD self_test ret codes are not hidden

Also fix a potential memory leak and an incorrect goto statement in
sha1.c self_test
This commit is contained in:
Andres Amaya Garcia
2017-07-20 14:18:54 +01:00
parent a21247ead7
commit 6a3f30514a
4 changed files with 42 additions and 25 deletions

View File

@ -464,7 +464,7 @@ static const unsigned char ripemd160_test_md[TESTS][20] =
*/
int mbedtls_ripemd160_self_test( int verbose )
{
int i, ret;
int i, ret = 0;
unsigned char output[20];
memset( output, 0, sizeof output );
@ -481,7 +481,10 @@ int mbedtls_ripemd160_self_test( int verbose )
goto fail;
if( memcmp( output, ripemd160_test_md[i], 20 ) != 0 )
{
ret = 1;
goto fail;
}
if( verbose != 0 )
mbedtls_printf( "passed\n" );
@ -496,7 +499,7 @@ fail:
if( verbose != 0 )
mbedtls_printf( "failed\n" );
return( 1 );
return( ret );
}
#endif /* MBEDTLS_SELF_TEST */