Skip to content

Commit

Permalink
lib-ssl-iostream: Do not handshake further if we are destroying
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Apr 18, 2018
1 parent a2de39b commit 9d06406
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib-ssl-iostream/iostream-openssl.c
Expand Up @@ -345,6 +345,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 */
Expand Down Expand Up @@ -631,6 +632,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,
Expand Down
1 change: 1 addition & 0 deletions src/lib-ssl-iostream/iostream-openssl.h
Expand Up @@ -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;
Expand Down

0 comments on commit 9d06406

Please sign in to comment.