diff options
author | jsing <> | 2021-09-04 14:31:54 +0000 |
---|---|---|
committer | jsing <> | 2021-09-04 14:31:54 +0000 |
commit | e5fd1ea5108181e48a2884ce779c8cfeff9d5ea1 (patch) | |
tree | b6c5106c5ee5243df831b45f229bcd8365c1d39f | |
parent | dee1e6cf24ed6de39feac8e8be7b300789269839 (diff) | |
download | openbsd-e5fd1ea5108181e48a2884ce779c8cfeff9d5ea1.tar.gz openbsd-e5fd1ea5108181e48a2884ce779c8cfeff9d5ea1.tar.bz2 openbsd-e5fd1ea5108181e48a2884ce779c8cfeff9d5ea1.zip |
Improve DTLS hello request handling code.
Rather than manually checking multiple bytes, actually parse the DTLS
handshake message header, then check the values against what we parsed.
ok inoguchi@ tb@
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 0b952cf5f3..aafadf16ef 100644 --- a/src/lib/libssl/d1_pkt.c +++ b/src/lib/libssl/d1_pkt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_pkt.c,v 1.111 2021/09/04 14:24:28 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.112 2021/09/04 14:31:54 jsing 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. |
@@ -681,7 +681,13 @@ dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
681 | rr->length >= DTLS1_HM_HEADER_LENGTH && rr->off == 0 && | 681 | rr->length >= DTLS1_HM_HEADER_LENGTH && rr->off == 0 && |
682 | rr->data[0] == SSL3_MT_HELLO_REQUEST && | 682 | rr->data[0] == SSL3_MT_HELLO_REQUEST && |
683 | s->session != NULL && s->session->cipher != NULL) { | 683 | s->session != NULL && s->session->cipher != NULL) { |
684 | if (rr->data[1] != 0 || rr->data[2] != 0 || rr->data[3] != 0) { | 684 | struct hm_header_st msg_hdr; |
685 | CBS cbs; | ||
686 | |||
687 | CBS_init(&cbs, rr->data, rr->length); | ||
688 | if (!dtls1_get_message_header(&cbs, &msg_hdr)) | ||
689 | return -1; | ||
690 | if (msg_hdr.msg_len != 0) { | ||
685 | al = SSL_AD_DECODE_ERROR; | 691 | al = SSL_AD_DECODE_ERROR; |
686 | SSLerror(s, SSL_R_BAD_HELLO_REQUEST); | 692 | SSLerror(s, SSL_R_BAD_HELLO_REQUEST); |
687 | goto fatal_err; | 693 | goto fatal_err; |