Disallow zero length signature algorithms
authorDr. Stephen Henson <steve@openssl.org>
Fri, 3 Mar 2017 02:44:18 +0000 (02:44 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 3 Mar 2017 21:58:33 +0000 (21:58 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2840)

ssl/statem/statem_srvr.c
ssl/t1_lib.c

index 7414c19..6c007a1 100644 (file)
@@ -2497,6 +2497,7 @@ int tls_construct_certificate_request(SSL *s, WPACKET *pkt)
         size_t nl = tls12_get_psigalgs(s, 1, &psigs);
 
         if (!WPACKET_start_sub_packet_u16(pkt)
+                || !WPACKET_set_flags(pkt, WPACKET_FLAGS_NON_ZERO_LENGTH)
                 || !tls12_copy_sigalgs(s, pkt, psigs, nl)
                 || !WPACKET_close(pkt)) {
             SSLerr(SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST,
index 87ef620..93a8cfe 100644 (file)
@@ -1563,7 +1563,7 @@ int tls1_save_sigalgs(SSL *s, PACKET *pkt)
     size = PACKET_remaining(pkt);
 
     /* Invalid data length */
-    if ((size & 1) != 0)
+    if (size == 0 || (size & 1) != 0)
         return 0;
 
     size >>= 1;