mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 19:15:37 +01:00
Fix memory leak and freeing without initialization in cert_write
* The variables `csr` and `issuer_crt` are initialized but not freed. * The variable `entropy` is unconditionally freed in the cleanup section but there's a conditional jump to that section before its initialization. This cmmot Moves it to the other initializations happening before the first conditional jump to the cleanup section. Fixes #1422.
This commit is contained in:
parent
5bcbd4e7f4
commit
b0d59a1084
@ -238,6 +238,7 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_pk_init( &loaded_subject_key );
|
||||
mbedtls_mpi_init( &serial );
|
||||
mbedtls_ctr_drbg_init( &ctr_drbg );
|
||||
mbedtls_entropy_init( &entropy );
|
||||
#if defined(MBEDTLS_X509_CSR_PARSE_C)
|
||||
mbedtls_x509_csr_init( &csr );
|
||||
#endif
|
||||
@ -472,7 +473,6 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( " . Seeding the random number generator..." );
|
||||
fflush( stdout );
|
||||
|
||||
mbedtls_entropy_init( &entropy );
|
||||
if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
|
||||
(const unsigned char *) pers,
|
||||
strlen( pers ) ) ) != 0 )
|
||||
@ -789,6 +789,10 @@ int main( int argc, char *argv[] )
|
||||
mbedtls_printf( " ok\n" );
|
||||
|
||||
exit:
|
||||
#if defined(MBEDTLS_X509_CSR_PARSE_C)
|
||||
mbedtls_x509_csr_free( &csr );
|
||||
#endif /* MBEDTLS_X509_CSR_PARSE_C */
|
||||
mbedtls_x509_crt_free( &issuer_crt );
|
||||
mbedtls_x509write_crt_free( &crt );
|
||||
mbedtls_pk_free( &loaded_subject_key );
|
||||
mbedtls_pk_free( &loaded_issuer_key );
|
||||
|
Loading…
Reference in New Issue
Block a user