Commit c80ce10841 for openssl.org

commit c80ce1084120e8286214132b059b95f233921aef
Author: Tomas Mraz <tomas@openssl.foundation>
Date:   Tue Jun 23 09:57:32 2026 +0200

    Always ignore the contents of the legacy record version

    As per RFC8446 this value must be ignored.

    Reviewed-by: Matt Caswell <matt@openssl.foundation>
    Reviewed-by: Daniel Kubec <kubec@openssl.foundation>
    MergeDate: Wed Jun 24 13:06:55 2026
    (Merged from https://github.com/openssl/openssl/pull/31662)

diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index 548104e73b..75278f39ee 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -834,14 +834,6 @@ start:
      * were actually expecting a CCS).
      */

-    /*
-     * Lets just double check that we've got a supported record version
-     */
-    if (rr->version < TLS1_VERSION || rr->version > TLS1_3_VERSION) {
-        SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
-        return -1;
-    }
-
     if (ssl->method->version == TLS_ANY_VERSION
         && (s->server || rr->type != SSL3_RT_ALERT)) {
         /*
@@ -850,7 +842,14 @@ start:
          * with. We shouldn't be receiving anything other than a ClientHello
          * if we are a server.
          */
-        s->version = rr->version;
+        int min_version, max_version;
+
+        if (ssl_get_min_max_version(s, &min_version, &max_version, NULL) != 0) {
+            SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, ERR_R_INTERNAL_ERROR);
+            return -1;
+        }
+
+        s->version = min_version;
         SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE);
         return -1;
     }