]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ssl/statem/statem_dtls.c: fix leak in dtls1_buffer_message()
authorhuanghuihui0904 <625173@qq.com>
Mon, 16 Mar 2026 07:16:21 +0000 (15:16 +0800)
committerEugene Syromiatnikov <esyr@openssl.org>
Sat, 21 Mar 2026 23:11:42 +0000 (00:11 +0100)
pqueue_insert() may fail, but its return value was not checked. This could leak the allocated pitem and handshake fragment. Free them when insertion fails, using pitem_free() for proper cleanup.

Solves https://github.com/openssl/openssl/issues/30442

Fixes #30442

Signed-off-by: huanghuihui0904 <625173@qq.com>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Sat Mar 21 23:11:54 2026
(Merged from https://github.com/openssl/openssl/pull/30443)

ssl/statem/statem_dtls.c

index 1644c6e47c64fa65d27d8621751aa327b2455b85..860d4c1c005b58cbab4edf369dc986daf55d5785 100644 (file)
@@ -1262,7 +1262,11 @@ int dtls1_buffer_message(SSL_CONNECTION *s, int is_ccs)
         return 0;
     }
 
-    pqueue_insert(s->d1->sent_messages, item);
+    if (pqueue_insert(s->d1->sent_messages, item) == NULL) {
+        dtls1_hm_fragment_free(frag);
+        pitem_free(item);
+        return 0;
+    }
     return 1;
 }