Check key_exchange data length is not 0
authorMatt Caswell <matt@openssl.org>
Fri, 4 Nov 2016 09:49:16 +0000 (09:49 +0000)
committerMatt Caswell <matt@openssl.org>
Wed, 16 Nov 2016 10:09:46 +0000 (10:09 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
ssl/t1_lib.c

index 2dbaa9f..6474c6d 100644 (file)
@@ -2754,7 +2754,8 @@ static int ssl_scan_serverhello_tlsext(SSL *s, PACKET *pkt, int *al)
 
             skey = ssl_generate_pkey(ckey);
 
-            if (!PACKET_as_length_prefixed_2(&spkt, &encoded_pt)) {
+            if (!PACKET_as_length_prefixed_2(&spkt, &encoded_pt)
+                    || PACKET_remaining(&encoded_pt) == 0) {
                 *al = SSL_AD_DECODE_ERROR;
                 SSLerr(SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT,
                        SSL_R_LENGTH_MISMATCH);