diff --git a/ChangeLog.d/fix_zeroization.txt b/ChangeLog.d/fix_zeroization.txt new file mode 100644 index 0000000000..ad74d9c59f --- /dev/null +++ b/ChangeLog.d/fix_zeroization.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix possible crash in TLS PRF code, if a failure to allocate memory occurs. + Reported by Michael Madsen in #6516. diff --git a/library/ssl_tls.c b/library/ssl_tls.c index a49f774ed1..3c91b45139 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -5635,7 +5635,9 @@ static int tls_prf_generic( mbedtls_md_type_t md_type, exit: mbedtls_md_free( &md_ctx ); - mbedtls_platform_zeroize( tmp, tmp_len ); + if ( tmp != NULL ) + mbedtls_platform_zeroize( tmp, tmp_len ); + mbedtls_platform_zeroize( h_i, sizeof( h_i ) ); mbedtls_free( tmp );