From 369f495afc4403abcd0ba9c372e0a64f456d0d17 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 1 Nov 2022 16:08:14 +0000 Subject: [PATCH 1/2] Fix zeroization at NULL pointer Signed-off-by: Dave Rodgman --- library/ssl_tls.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 7a4d43791..c752d59d0 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -760,7 +760,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 ); From febe14e6e0635b0a3c020bb1d552c7e221a189ac Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 1 Nov 2022 16:27:14 +0000 Subject: [PATCH 2/2] Add Changelog Signed-off-by: Dave Rodgman --- ChangeLog.d/fix_zeroization.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ChangeLog.d/fix_zeroization.txt diff --git a/ChangeLog.d/fix_zeroization.txt b/ChangeLog.d/fix_zeroization.txt new file mode 100644 index 000000000..ad74d9c59 --- /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.