From: Matt Caswell Date: Wed, 4 Nov 2015 11:20:50 +0000 (+0000) Subject: Ensure |rwstate| is set correctly on BIO_flush X-Git-Tag: OpenSSL_1_1_0-pre1~5 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=67f60be8c9ae5ff3129fcd6238baf124385a41d8 Ensure |rwstate| is set correctly on BIO_flush A BIO_flush call in the DTLS code was not correctly setting the |rwstate| variable to SSL_WRITING. This means that SSL_get_error() will not return SSL_ERROR_WANT_WRITE in the event of an IO retry. Reviewed-by: Richard Levitte --- diff --git a/ssl/statem/statem_dtls.c b/ssl/statem/statem_dtls.c index 44c5c1322f..5194c7308e 100644 --- a/ssl/statem/statem_dtls.c +++ b/ssl/statem/statem_dtls.c @@ -250,6 +250,8 @@ int dtls1_do_write(SSL *s, int type) blocksize = 0; frag_off = 0; + s->rwstate = SSL_NOTHING; + /* s->init_num shouldn't ever be < 0...but just in case */ while (s->init_num > 0) { if (type == SSL3_RT_HANDSHAKE && s->init_off != 0) { @@ -298,8 +300,10 @@ int dtls1_do_write(SSL *s, int type) * grr.. we could get an error if MTU picked was wrong */ ret = BIO_flush(SSL_get_wbio(s)); - if (ret <= 0) + if (ret <= 0) { + s->rwstate = SSL_WRITING; return ret; + } used_len = DTLS1_RT_HEADER_LENGTH + mac_size + blocksize; if (s->d1->mtu > used_len + DTLS1_HM_HEADER_LENGTH) { curr_mtu = s->d1->mtu - used_len;