From: Matt Caswell Date: Thu, 12 May 2016 16:18:32 +0000 (+0100) Subject: Ensure async IO works with new state machine X-Git-Tag: OpenSSL_1_1_0-pre6~754 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1689e7e688b3b0ae492932b07f2626f8a4e1e664;p=oweals%2Fopenssl.git Ensure async IO works with new state machine In the new state machine if using nbio and we get the header of a handshake message is one record with the body in the next, with an nbio event in the middle, then the connection was failing. This is because s->init_num was getting reset. We should only reset it after we have read the whole message. RT#4394 Reviewed-by: Andy Polyakov --- diff --git a/ssl/statem/statem.c b/ssl/statem/statem.c index 20353c305b..0b0595d237 100644 --- a/ssl/statem/statem.c +++ b/ssl/statem/statem.c @@ -500,7 +500,6 @@ static SUB_STATE_RETURN read_state_machine(SSL *s) { while(1) { switch(st->read_state) { case READ_STATE_HEADER: - s->init_num = 0; /* Get the state the peer wants to move to */ if (SSL_IS_DTLS(s)) { /* @@ -559,6 +558,10 @@ static SUB_STATE_RETURN read_state_machine(SSL *s) { return SUB_STATE_ERROR; } ret = process_message(s, &pkt); + + /* Discard the packet data */ + s->init_num = 0; + if (ret == MSG_PROCESS_ERROR) { return SUB_STATE_ERROR; }