diff -ur gnutls-3.1.18.orig/lib/gnutls_handshake.c gnutls-3.1.18/lib/gnutls_handshake.c
--- gnutls-3.1.18.orig/lib/gnutls_handshake.c 2013-11-15 18:10:53.000000000 +0100
+++ gnutls-3.1.18/lib/gnutls_handshake.c 2014-05-28 13:43:50.922689540 +0200
@@ -1679,7 +1679,7 @@
DECR_LEN (len, 1);
session_id_len = data[pos++];
- if (len < session_id_len)
+ if (len < session_id_len || session_id_len > TLS_MAX_SESSION_ID_SIZE)
{
gnutls_assert ();
return GNUTLS_E_UNSUPPORTED_VERSION_PACKET;