diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2011-09-23 13:35:32 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2011-09-23 13:35:32 +0000 |
commit | fc4015329fdec9f42baf059c5ae818b692f23e70 (patch) | |
tree | c50407c6e6836438943cf3eb43211ae2bb1020a2 /ssl | |
parent | 6ec9ff83f3aa011a321bab4040d6a2f3b4dc7ef1 (diff) |
PR: 2602
Submitted by: Robin Seggelmann <seggelmann@fh-muenster.de>
Reviewed by: steve
Fix DTLS bug which prevents manual MTU setting
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/d1_both.c | 8 | ||||
-rw-r--r-- | ssl/d1_lib.c | 9 | ||||
-rw-r--r-- | ssl/ssl_lib.c | 3 | ||||
-rw-r--r-- | ssl/ssl_locl.h | 1 |
4 files changed, 15 insertions, 6 deletions
diff --git a/ssl/d1_both.c b/ssl/d1_both.c index df684e57fa..1c4158d36d 100644 --- a/ssl/d1_both.c +++ b/ssl/d1_both.c @@ -158,7 +158,6 @@ static unsigned char bitmask_end_values[] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1 /* XDTLS: figure out the right values */ static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28}; -static unsigned int dtls1_min_mtu(void); static unsigned int dtls1_guess_mtu(unsigned int curr_mtu); static void dtls1_fix_message_header(SSL *s, unsigned long frag_off, unsigned long frag_len); @@ -264,11 +263,10 @@ int dtls1_do_write(SSL *s, int type) return ret; mtu = s->d1->mtu - (DTLS1_HM_HEADER_LENGTH + DTLS1_RT_HEADER_LENGTH); } - - OPENSSL_assert(mtu > 0); /* should have something reasonable now */ - #endif + OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu()); /* should have something reasonable now */ + if ( s->init_off == 0 && type == SSL3_RT_HANDSHAKE) OPENSSL_assert(s->init_num == (int)s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH); @@ -1371,7 +1369,7 @@ dtls1_write_message_header(SSL *s, unsigned char *p) return p; } -static unsigned int +unsigned int dtls1_min_mtu(void) { return (g_probable_mtu[(sizeof(g_probable_mtu) / diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index 736216f6aa..2e57b63101 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -226,7 +226,8 @@ void dtls1_clear(SSL *s) pqueue buffered_messages; pqueue sent_messages; pqueue buffered_app_data; - + unsigned int mtu; + if (s->d1) { unprocessed_rcds = s->d1->unprocessed_rcds.q; @@ -234,6 +235,7 @@ void dtls1_clear(SSL *s) buffered_messages = s->d1->buffered_messages; sent_messages = s->d1->sent_messages; buffered_app_data = s->d1->buffered_app_data.q; + mtu = s->d1->mtu; dtls1_clear_queues(s); @@ -250,6 +252,11 @@ void dtls1_clear(SSL *s) s->d1->cookie_len = sizeof(s->d1->cookie); } + if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU) + { + s->d1->mtu = mtu; + } + s->d1->unprocessed_rcds.q = unprocessed_rcds; s->d1->processed_rcds.q = processed_rcds; s->d1->buffered_messages = buffered_messages; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index b6b8e6038a..d88b52f289 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1000,6 +1000,9 @@ long SSL_ctrl(SSL *s,int cmd,long larg,void *parg) s->max_cert_list=larg; return(l); case SSL_CTRL_SET_MTU: + if (larg < dtls1_min_mtu()) + return 0; + if (SSL_version(s) == DTLS1_VERSION || SSL_version(s) == DTLS1_BAD_VER) { diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index e305db43ff..4741e30b2b 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -877,6 +877,7 @@ void dtls1_stop_timer(SSL *s); int dtls1_is_timer_expired(SSL *s); void dtls1_double_timeout(SSL *s); int dtls1_send_newsession_ticket(SSL *s); +unsigned int dtls1_min_mtu(void); /* some client-only functions */ |