From a20718fa2c0a45e6acb975cf6c0438c3ebd45b13 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 5 Feb 2015 13:59:16 +0000 Subject: [PATCH] Add ticket length before buffering DTLS message In ssl3_send_new_session_ticket the message to be sent is constructed. We skip adding the length of the session ticket initially, then call ssl_set_handshake_header, and finally go back and add in the length of the ticket. Unfortunately, in DTLS, ssl_set_handshake_header also has the side effect of buffering the message for subsequent retransmission if required. By adding the ticket length after the call to ssl_set_handshake_header the message that is buffered is incomplete, causing an invalid message to be sent on retransmission. Reviewed-by: Richard Levitte (cherry picked from commit 4f9fab6bd0253416eeace5a45142c7c4a83bc511) Conflicts: ssl/s3_srvr.c --- ssl/s3_srvr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index c016139b1d..f7ffa06725 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -3391,10 +3391,10 @@ int ssl3_send_newsession_ticket(SSL *s) /* Now write out lengths: p points to end of data written */ /* Total length */ len = p - ssl_handshake_start(s); - ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len); /* Skip ticket lifetime hint */ p = ssl_handshake_start(s) + 4; s2n(len - 6, p); + ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len); s->state = SSL3_ST_SW_SESSION_TICKET_B; OPENSSL_free(senc); } -- 2.40.0