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:17:01 +0000 (20:17 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #2050

ssl/statem/statem_clnt.c

index 35ca8defa90d6b11309e861f61edd7d4850c4cfb..9b9d6cd6c746d4706e0f20e2f95d731c352f121b 100644 (file)
@@ -1186,8 +1186,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 */