Fix length check writing status request extension
authorMatt Caswell <matt@openssl.org>
Fri, 14 Oct 2016 10:49:06 +0000 (11:49 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 28 Oct 2016 08:43:41 +0000 (09:43 +0100)
The status request extension did not correctly check its length, meaning
that writing the extension could go 2 bytes beyond the buffer size. In
practice this makes little difference because, due to logic in buffer.c the
buffer is actually over allocated by approximately 5k!

Issue reported by Guido Vranken.

Reviewed-by: Rich Salz <rsalz@openssl.org>
ssl/t1_lib.c

index 7831046b9261396451d6bad61c8941f865a2e944..e53c76e0b314347d98545fbb7856fdade7ba898d 100644 (file)
@@ -1479,7 +1479,14 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf,
         } else
             extlen = 0;
 
-        if ((long)(limit - ret - 7 - extlen - idlen) < 0)
+        /*
+         * 2 bytes for status request type
+         * 2 bytes for status request len
+         * 1 byte for OCSP request type
+         * 2 bytes for length of ids
+         * 2 bytes for length of extensions
+         */
+        if ((long)(limit - ret - 9 - extlen - idlen) < 0)
             return NULL;
         s2n(TLSEXT_TYPE_status_request, ret);
         if (extlen + idlen > 0xFFF0)