]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ssl: call SSLfatal on realloc failures in extract_keyshares
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 11 Oct 2025 11:53:07 +0000 (19:53 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 14 Oct 2025 16:01:45 +0000 (18:01 +0200)
Initial malloc path already does this. Realloc path went to failure
without recording a fatal alert.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28873)

ssl/statem/extensions_srvr.c

index 81c251523b6facd957289ac00d57a02667b888b1..09f653d03d4f3127008390e2a9bb950391169380 100644 (file)
@@ -756,15 +756,21 @@ static KS_EXTRACTION_RESULT extract_keyshares(SSL_CONNECTION *s, PACKET *key_sha
                                       *keyshares_max + GROUPLIST_INCREMENT,
                                       sizeof(**keyshares_arr));
 
-            if (tmp == NULL)
+            if (tmp == NULL) {
+                SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
                 goto failure;
+            }
+
             *keyshares_arr = tmp;
             tmp_pkt =
                 OPENSSL_realloc_array(*encoded_pubkey_arr,
                                       *keyshares_max + GROUPLIST_INCREMENT,
                                       sizeof(**encoded_pubkey_arr));
-            if (tmp_pkt == NULL)
+            if (tmp_pkt == NULL) {
+                SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
                 goto failure;
+            }
+
             *encoded_pubkey_arr = tmp_pkt;
             *keyshares_max += GROUPLIST_INCREMENT;
         }