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 11:28:17 +0000 (11:28 +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>
Conflicts:
ssl/s3_pkt.c

ssl/d1_pkt.c
ssl/s3_pkt.c

index d12604e6573eb60f8d0938a186403d5d05479a7b..5eac25fbddadf1dd22aaab0f5dddeaef12057605 100644 (file)
@@ -595,8 +595,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 a3b45fba9dc1a16f32200f906a5203f437b2a398..1adc30191138c0948625e63d83b095ba46076583 100644 (file)
@@ -147,6 +147,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)
                {
+               if (s->s3->rbuf.left == 0 && extend)
+                       return 0;
                if ( s->s3->rbuf.left > 0 && n > s->s3->rbuf.left)
                        n = s->s3->rbuf.left;
                }