File openssl-CVE-2014-3571.patch of Package openssl.1634
commit 45fe66b8ba026186aa5d8ef1e0e6010ea74d5c0b
Author: Matt Caswell <matt@openssl.org>
Date: Sat Jan 3 00:54:35 2015 +0000
Follow on from CVE-2014-3571. This fixes the code that was the original source
of the crash due to p being NULL. Steve's fix prevents this situation from
occuring - however this is by no means obvious by looking at the code for
dtls1_get_record. This fix just makes things look a bit more sane.
Reviewed-by: Dr Steve Henson <steve@openssl.org>
commit 8d7aab986b499f34d9e1bc58fbfd77f05c38116e
Author: Dr. Stephen Henson <steve@openssl.org>
Date: Sat Jan 3 00:45:13 2015 +0000
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 <matt@openssl.org>
diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c
index d717260..73ce488 100644
--- a/ssl/d1_pkt.c
+++ b/ssl/d1_pkt.c
@@ -676,7 +676,8 @@ again:
* would be dropped unnecessarily.
*/
if (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE &&
- *p == SSL3_MT_CLIENT_HELLO) &&
+ s->packet_length > DTLS1_RT_HEADER_LENGTH &&
+ s->packet[DTLS1_RT_HEADER_LENGTH] == SSL3_MT_CLIENT_HELLO) &&
!dtls1_record_replay_check(s, bitmap))
{
rr->length = 0;
diff --git a/ssl/d1_pkt.c b/ssl/d1_pkt.c
index edd17df..d717260 100644
--- a/ssl/d1_pkt.c
+++ b/ssl/d1_pkt.c
@@ -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)
{
diff --git a/ssl/s3_pkt.c b/ssl/s3_pkt.c
index d1cd752..1ec9e6e 100644
--- a/ssl/s3_pkt.c
+++ b/ssl/s3_pkt.c
@@ -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;
}