From 25d738c3a46339730e990391ca6399158636473e Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sat, 3 Jan 2015 00:45:13 +0000 Subject: [PATCH] Fix crash in dtls1_get_record whilst in the listen state where you get two separate reads performed - one for the header and one for the body of the handshake record. CVE-2014-3571 Reviewed-by: Matt Caswell --- ssl/d1_pkt.c | 2 -- ssl/s3_pkt.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c index dc5b6f40c4..b76703a5e0 100644 --- a/ssl/d1_pkt.c +++ b/ssl/d1_pkt.c @@ -645,8 +645,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) { diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c index 0804d556a1..6a2ec5c579 100644 --- a/ssl/s3_pkt.c +++ b/ssl/s3_pkt.c @@ -197,6 +197,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_IS_DTLS(s)) { + if (left == 0 && extend) + return 0; if (left > 0 && n > left) n = left; } -- 2.25.1