Commit 21d4b79c0b for openssl.org

commit 21d4b79c0b9c8a585e226cf3cc4e228affc3e2d3
Author: Alexandre Laroche <larochealexandre@hotmail.com>
Date:   Thu Nov 12 16:12:00 2026 -0500

    statem_srvr.c: clear the freed inner ClientHello pointer in tls_process_client_hello()

    On the ECH backend path, s->ext.ech.innerch was freed, but the pointer
    to it was kept until the buffer replacing it was allocated.  An error
    condition in between could lead to a jump to err:, where a second attempt
    to free s->ext.ech.innerch could be made.  The only such error today,
    the PACKET_peek_bytes() of PACKET_remaining() bytes, cannot happen,
    but the pointer should not outlive the buffer.

    Complements: 6c3edd4f3a8a "Add server-side handling of Encrypted Client Hello"
    Assisted-by: Claude Code:claude-opus-5-5
    Reviewed-by: Milan Broz <gmazyland@gmail.com>
    Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
    Merge-date: Fri Nov 20 14:19:23 2026
    Merged-from: https://github.com/openssl/openssl/pull/33705

diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c
index f9561a2d23..efda816487 100644
--- a/ssl/statem/statem_srvr.c
+++ b/ssl/statem/statem_srvr.c
@@ -2066,6 +2066,7 @@ MSG_PROCESS_RETURN tls_process_client_hello(SSL_CONNECTION *s, PACKET *pkt)
             s->ext.ech.backend = 1;
             s->ext.ech.attempted_type = TLSEXT_TYPE_ech;
             OPENSSL_free(s->ext.ech.innerch);
+            s->ext.ech.innerch = NULL;
             s->ext.ech.innerch_len = PACKET_remaining(pkt);
             if (PACKET_peek_bytes(pkt, &pbuf, s->ext.ech.innerch_len) != 1) {
                 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);