diff options
author | guenther <> | 2014-08-08 05:06:56 +0000 |
---|---|---|
committer | guenther <> | 2014-08-08 05:06:56 +0000 |
commit | 2bf89d3e6a8ea56f877482b2550aa4da739bae86 (patch) | |
tree | 887f4dc66996ca4a746f32e0499cb49ea2fef935 | |
parent | c6985e683db078656f9f4ec499be1ef35bdce285 (diff) | |
download | openbsd-2bf89d3e6a8ea56f877482b2550aa4da739bae86.tar.gz openbsd-2bf89d3e6a8ea56f877482b2550aa4da739bae86.tar.bz2 openbsd-2bf89d3e6a8ea56f877482b2550aa4da739bae86.zip |
Fix CVE-2014-3507, avoid allocating and then leaking a fresh fragment
structure when a zero-length fragment is received.
Based on
https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=d0a4b7d1a2948fce38515b8d862f43e7ba0ebf74
diff by miod@, ok guenther@ bcook@ deraadt@
-rw-r--r-- | src/lib/libssl/d1_both.c | 9 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/d1_both.c | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index fea701107f..1eda4aef72 100644 --- a/src/lib/libssl/d1_both.c +++ b/src/lib/libssl/d1_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_both.c,v 1.27 2014/08/07 20:24:12 guenther Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.28 2014/08/08 05:06:56 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -597,6 +597,11 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok) | |||
597 | msg_hdr->msg_len > dtls1_max_handshake_message_len(s)) | 597 | msg_hdr->msg_len > dtls1_max_handshake_message_len(s)) |
598 | goto err; | 598 | goto err; |
599 | 599 | ||
600 | if (frag_len == 0) { | ||
601 | i = DTLS1_HM_FRAGMENT_RETRY; | ||
602 | goto err; | ||
603 | } | ||
604 | |||
600 | /* Try to find item in queue */ | 605 | /* Try to find item in queue */ |
601 | memset(seq64be, 0, sizeof(seq64be)); | 606 | memset(seq64be, 0, sizeof(seq64be)); |
602 | seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); | 607 | seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); |
@@ -725,7 +730,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) | |||
725 | frag_len -= i; | 730 | frag_len -= i; |
726 | } | 731 | } |
727 | } else { | 732 | } else { |
728 | if (frag_len && frag_len < msg_hdr->msg_len) | 733 | if (frag_len < msg_hdr->msg_len) |
729 | return dtls1_reassemble_fragment(s, msg_hdr, ok); | 734 | return dtls1_reassemble_fragment(s, msg_hdr, ok); |
730 | 735 | ||
731 | if (frag_len > dtls1_max_handshake_message_len(s)) | 736 | if (frag_len > dtls1_max_handshake_message_len(s)) |
diff --git a/src/lib/libssl/src/ssl/d1_both.c b/src/lib/libssl/src/ssl/d1_both.c index fea701107f..1eda4aef72 100644 --- a/src/lib/libssl/src/ssl/d1_both.c +++ b/src/lib/libssl/src/ssl/d1_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_both.c,v 1.27 2014/08/07 20:24:12 guenther Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.28 2014/08/08 05:06:56 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -597,6 +597,11 @@ dtls1_reassemble_fragment(SSL *s, struct hm_header_st* msg_hdr, int *ok) | |||
597 | msg_hdr->msg_len > dtls1_max_handshake_message_len(s)) | 597 | msg_hdr->msg_len > dtls1_max_handshake_message_len(s)) |
598 | goto err; | 598 | goto err; |
599 | 599 | ||
600 | if (frag_len == 0) { | ||
601 | i = DTLS1_HM_FRAGMENT_RETRY; | ||
602 | goto err; | ||
603 | } | ||
604 | |||
600 | /* Try to find item in queue */ | 605 | /* Try to find item in queue */ |
601 | memset(seq64be, 0, sizeof(seq64be)); | 606 | memset(seq64be, 0, sizeof(seq64be)); |
602 | seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); | 607 | seq64be[6] = (unsigned char)(msg_hdr->seq >> 8); |
@@ -725,7 +730,7 @@ dtls1_process_out_of_seq_message(SSL *s, struct hm_header_st* msg_hdr, int *ok) | |||
725 | frag_len -= i; | 730 | frag_len -= i; |
726 | } | 731 | } |
727 | } else { | 732 | } else { |
728 | if (frag_len && frag_len < msg_hdr->msg_len) | 733 | if (frag_len < msg_hdr->msg_len) |
729 | return dtls1_reassemble_fragment(s, msg_hdr, ok); | 734 | return dtls1_reassemble_fragment(s, msg_hdr, ok); |
730 | 735 | ||
731 | if (frag_len > dtls1_max_handshake_message_len(s)) | 736 | if (frag_len > dtls1_max_handshake_message_len(s)) |