Fix crash in dtls1_get_record whilst in the listen state where you get two
authorDr. Stephen Henson <steve@openssl.org>
Sat, 3 Jan 2015 00:45:13 +0000 (00:45 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 8 Jan 2015 13:43:20 +0000 (13:43 +0000)
separate reads performed - one for the header and one for the body of the
handshake record.

CVE-2014-3571

Reviewed-by: Matt Caswell <matt@openssl.org>
ssl/d1_pkt.c
ssl/s3_pkt.c

index edd17df54b50acb05d68832b261ac3ef5d98b96a..d7172603130c8c790d986d50f0686bd575733001 100644 (file)
@@ -642,8 +642,6 @@ again:
                /* now s->packet_length == DTLS1_RT_HEADER_LENGTH */
                i=rr->length;
                n=ssl3_read_n(s,i,i,1);
-               if (n <= 0) return(n); /* error or non-blocking io */
-
                /* this packet contained a partial record, dump it */
                if ( n != i)
                        {
index d1cd752209ff973162a1882feb1a6f15181b3a56..1ec9e6ea46daeaa20ff032296a7afaec6b562786 100644 (file)
@@ -183,6 +183,8 @@ int ssl3_read_n(SSL *s, int n, int max, int extend)
         * at once (as long as it fits into the buffer). */
        if (SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER)
                {
+               if (left == 0 && extend)
+                       return 0;
                if (left > 0 && n > left)
                        n = left;
                }