mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-22 19:15:36 +00:00
Merge remote-tracking branch 'origin/pr/2514' into mbedtls-2.16
* origin/pr/2514: x509.c: Fix potential memory leak in X.509 self test
This commit is contained in:
commit
749c944664
|
@ -21,6 +21,8 @@ Bugfix
|
|||
* Fix private key DER output in the key_app_writer example. File contents
|
||||
were shifted by one byte, creating an invalid ASN.1 tag. Fixed by
|
||||
Christian Walther in #2239.
|
||||
* Fix potential memory leak in X.509 self test. Found and fixed by
|
||||
Junhwan Park, #2106.
|
||||
|
||||
Changes
|
||||
* Return from various debugging routines immediately if the
|
||||
|
|
|
@ -1001,8 +1001,8 @@ int mbedtls_x509_time_is_future( const mbedtls_x509_time *from )
|
|||
*/
|
||||
int mbedtls_x509_self_test( int verbose )
|
||||
{
|
||||
int ret = 0;
|
||||
#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_SHA256_C)
|
||||
int ret;
|
||||
uint32_t flags;
|
||||
mbedtls_x509_crt cacert;
|
||||
mbedtls_x509_crt clicert;
|
||||
|
@ -1010,6 +1010,7 @@ int mbedtls_x509_self_test( int verbose )
|
|||
if( verbose != 0 )
|
||||
mbedtls_printf( " X.509 certificate load: " );
|
||||
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
mbedtls_x509_crt_init( &clicert );
|
||||
|
||||
ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt,
|
||||
|
@ -1019,11 +1020,9 @@ int mbedtls_x509_self_test( int verbose )
|
|||
if( verbose != 0 )
|
||||
mbedtls_printf( "failed\n" );
|
||||
|
||||
return( ret );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
mbedtls_x509_crt_init( &cacert );
|
||||
|
||||
ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_ca_crt,
|
||||
mbedtls_test_ca_crt_len );
|
||||
if( ret != 0 )
|
||||
|
@ -1031,7 +1030,7 @@ int mbedtls_x509_self_test( int verbose )
|
|||
if( verbose != 0 )
|
||||
mbedtls_printf( "failed\n" );
|
||||
|
||||
return( ret );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( verbose != 0 )
|
||||
|
@ -1043,20 +1042,19 @@ int mbedtls_x509_self_test( int verbose )
|
|||
if( verbose != 0 )
|
||||
mbedtls_printf( "failed\n" );
|
||||
|
||||
return( ret );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( verbose != 0 )
|
||||
mbedtls_printf( "passed\n\n");
|
||||
|
||||
cleanup:
|
||||
mbedtls_x509_crt_free( &cacert );
|
||||
mbedtls_x509_crt_free( &clicert );
|
||||
|
||||
return( 0 );
|
||||
#else
|
||||
((void) verbose);
|
||||
return( 0 );
|
||||
#endif /* MBEDTLS_CERTS_C && MBEDTLS_SHA1_C */
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
|
Loading…
Reference in a new issue