]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
zero data in hm_fragment on alloc
authorNeil Horman <nhorman@openssl.org>
Thu, 9 Nov 2023 13:13:58 +0000 (08:13 -0500)
committerRichard Levitte <levitte@openssl.org>
Tue, 21 Nov 2023 12:09:28 +0000 (13:09 +0100)
if we allocate a new hm_frament in dtls1_buffer_message with
dtls1_hm_fragment_new, the returned fragment contains uninitalized data in the
msg_header field.  If an error then occurs, and we free the fragment,
dtls_hm_fragment_free interrogates the msg_header field (which is garbage), and
potentially references undefined values, or worse, accidentally references
available memory that is not owned, leading to various corruptions.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22679)

ssl/statem/statem_dtls.c

index a88b0dfeac61af992b9c28e6289c2f1c4f45d937..97d9f4591c131d658d8c7d100246d9d0b1b64cb9 100644 (file)
@@ -62,7 +62,7 @@ static hm_fragment *dtls1_hm_fragment_new(size_t frag_len, int reassembly)
     unsigned char *buf = NULL;
     unsigned char *bitmask = NULL;
 
-    if ((frag = OPENSSL_malloc(sizeof(*frag))) == NULL)
+    if ((frag = OPENSSL_zalloc(sizeof(*frag))) == NULL)
         return NULL;
 
     if (frag_len) {