diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-06-16 11:37:30 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-06-16 11:55:19 +0200 |
commit | 3051e4e07d30b81ca3b1b44e9d6b4ee04e5911a1 (patch) | |
tree | fb398caa3660cc8c7fe71fb04c75f93272761cca | |
parent | 1b74ddbabbe8610873b6e6d073a32ec8a0444a2c (diff) | |
download | gnutls-3051e4e07d30b81ca3b1b44e9d6b4ee04e5911a1.tar.gz |
dtls: corrected reconstruction of handshake packets received out of order
That is, when the handshake packet is split into multiple different
chunks and received out of order, make sure that reconstruction occurs
properly. Reported by Guillaume Roguez.
-rw-r--r-- | lib/gnutls_buffers.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c index 8fc714b3b1..8750863120 100644 --- a/lib/gnutls_buffers.c +++ b/lib/gnutls_buffers.c @@ -976,14 +976,14 @@ static int merge_handshake_packet(gnutls_session_t session, } } - if (exists == 0) + if (!exists) pos = session->internals.handshake_recv_buffer_size; if (pos >= MAX_HANDSHAKE_MSGS) return gnutls_assert_val(GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS); - if (exists == 0) { + if (!exists) { if (hsk->length > 0 && hsk->end_offset > 0 && hsk->end_offset - hsk->start_offset + 1 != hsk->length) { @@ -1014,7 +1014,7 @@ static int merge_handshake_packet(gnutls_session_t session, if (hsk->start_offset < session->internals.handshake_recv_buffer[pos]. start_offset - && hsk->end_offset >= + && hsk->end_offset + 1 >= session->internals.handshake_recv_buffer[pos]. start_offset) { memcpy(&session->internals. @@ -1171,7 +1171,7 @@ int _gnutls_parse_record_buffered_msgs(gnutls_session_t session) gnutls_assert_val (GNUTLS_E_UNEXPECTED_PACKET); - /* if we have a half received message the complete it. + /* if we have a half received message then complete it. */ remain = recv_buf[0].length - recv_buf[0].data.length; |