From: Aki Tuomi Date: Tue, 17 Apr 2018 12:58:58 +0000 (+0300) Subject: lib-ssl-iostream: Do not handshake further if we are destroying X-Git-Tag: 2.3.2.rc1~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e165a7553032f01f594b789e9e21f1bf47005356;p=thirdparty%2Fdovecot%2Fcore.git lib-ssl-iostream: Do not handshake further if we are destroying --- diff --git a/src/lib-ssl-iostream/iostream-openssl.c b/src/lib-ssl-iostream/iostream-openssl.c index a8ce19ad41..d1459d4069 100644 --- a/src/lib-ssl-iostream/iostream-openssl.c +++ b/src/lib-ssl-iostream/iostream-openssl.c @@ -344,6 +344,7 @@ static void openssl_iostream_unref(struct ssl_iostream *ssl_io) static void openssl_iostream_destroy(struct ssl_iostream *ssl_io) { + ssl_io->destroyed = TRUE; if (ssl_io->handshaked && SSL_shutdown(ssl_io->ssl) != 1) { /* if bidirectional shutdown fails we need to clear the error queue */ @@ -628,6 +629,10 @@ static int openssl_iostream_handshake(struct ssl_iostream *ssl_io) i_assert(!ssl_io->handshaked); + /* we are being destroyed, so do not do any more handshaking */ + if (ssl_io->destroyed) + return 0; + if (ssl_io->ctx->client_ctx) { while ((ret = SSL_connect(ssl_io->ssl)) <= 0) { ret = openssl_iostream_handle_error(ssl_io, ret, diff --git a/src/lib-ssl-iostream/iostream-openssl.h b/src/lib-ssl-iostream/iostream-openssl.h index 9cefe2d0e9..ca34fae623 100644 --- a/src/lib-ssl-iostream/iostream-openssl.h +++ b/src/lib-ssl-iostream/iostream-openssl.h @@ -66,6 +66,7 @@ struct ssl_iostream { bool want_read:1; bool ostream_flush_waiting_input:1; bool closed:1; + bool destroyed:1; }; extern int dovecot_ssl_extdata_index;