statem/statem_clnt.c: omit redundant check in tls_construct_client_hello.
authorPhilippe Antoine <p.antoine@catenacyber.fr>
Mon, 26 Mar 2018 08:29:56 +0000 (10:29 +0200)
committerAndy Polyakov <appro@openssl.org>
Tue, 27 Mar 2018 18:03:15 +0000 (20:03 +0200)
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5729)

ssl/statem/statem_clnt.c

index 86cf5b6ab221a153c4465d4352298de62dfbe4ac..e940fc8e98ffd416c9d2be335ff4613de90c0460 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <stdio.h>
 #include <time.h>
+#include <assert.h>
 #include "../ssl_locl.h"
 #include "statem_locl.h"
 #include <openssl/buffer.h>
@@ -1198,14 +1199,14 @@ int tls_construct_client_hello(SSL *s, WPACKET *pkt)
             sess_id_len = 0;
         }
     } else {
+        assert(s->session->session_id_length <= sizeof(s->session->session_id));
         sess_id_len = s->session->session_id_length;
         if (s->version == TLS1_3_VERSION) {
             s->tmp_session_id_len = sess_id_len;
             memcpy(s->tmp_session_id, s->session->session_id, sess_id_len);
         }
     }
-    if (sess_id_len > sizeof(s->session->session_id)
-            || !WPACKET_start_sub_packet_u8(pkt)
+    if (!WPACKET_start_sub_packet_u8(pkt)
             || (sess_id_len != 0 && !WPACKET_memcpy(pkt, session_id,
                                                     sess_id_len))
             || !WPACKET_close(pkt)) {