Only call memcpy when the length is larger than 0.
authorKurt Roeckx <kurt@roeckx.be>
Thu, 8 Dec 2016 18:20:55 +0000 (19:20 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Thu, 8 Dec 2016 19:23:41 +0000 (20:23 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #2050
(cherry picked from commit a19fc66a6b5f99ad00305e152bdb41460d728640)

ssl/statem/statem_clnt.c

index 5ea0919e4ac0bb81893b636659357fbdad136b39..a7cf227ce4da71b39d5da6fe53a6f8ced8174d84 100644 (file)
@@ -1022,8 +1022,9 @@ MSG_PROCESS_RETURN tls_process_server_hello(SSL *s, PACKET *pkt)
         s->session->ssl_version = s->version;
         s->session->session_id_length = session_id_len;
         /* session_id_len could be 0 */
-        memcpy(s->session->session_id, PACKET_data(&session_id),
-               session_id_len);
+        if (session_id_len > 0)
+            memcpy(s->session->session_id, PACKET_data(&session_id),
+                   session_id_len);
     }
 
     /* Session version and negotiated protocol version should match */