Check there is enough room for extension.
authorDavid Benjamin <davidben@google.com>
Mon, 2 Jun 2014 17:55:20 +0000 (18:55 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 2 Jun 2014 22:55:56 +0000 (23:55 +0100)
ssl/t1_lib.c

index c4e27b972b26c673cb985989aee19dd96ea53f76..cf007f9cce62e4e33460e55c77756d4a41be71b7 100644 (file)
@@ -1416,6 +1416,8 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *p, unsigned cha
 
 #ifndef OPENSSL_NO_HEARTBEATS
        /* Add Heartbeat extension */
+       if ((limit - ret - 4 - 1) < 0)
+               return NULL;
        s2n(TLSEXT_TYPE_heartbeat,ret);
        s2n(1,ret);
        /* Set mode:
@@ -1698,6 +1700,8 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *p, unsigned cha
        /* Add Heartbeat extension if we've received one */
        if (s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED)
                {
+               if ((limit - ret - 4 - 1) < 0)
+                       return NULL;
                s2n(TLSEXT_TYPE_heartbeat,ret);
                s2n(1,ret);
                /* Set mode: