Skip to content

Commit

Permalink
lib-ssl-iostream: Shutdown connection cleanly whenever i/ostream is d…
Browse files Browse the repository at this point in the history
…estroyed

Do this while both istream and ostream still exist. Fixes crash where
openssl_iostream_destroy() attempts to flush the shutdown, but ssl_input
is NULL and it crashes.
  • Loading branch information
sirainen committed Jul 9, 2018
1 parent c6d7e0d commit 6c7efd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib-ssl-iostream/istream-openssl.c
Expand Up @@ -23,6 +23,7 @@ static void i_stream_ssl_destroy(struct iostream_private *stream)
{
struct ssl_istream *sstream = (struct ssl_istream *)stream;

openssl_iostream_shutdown(sstream->ssl_io);
i_stream_free_buffer(&sstream->istream);
sstream->ssl_io->ssl_input = NULL;
ssl_iostream_unref(&sstream->ssl_io);
Expand Down
1 change: 1 addition & 0 deletions src/lib-ssl-iostream/ostream-openssl.c
Expand Up @@ -26,6 +26,7 @@ static void o_stream_ssl_destroy(struct iostream_private *stream)
struct ssl_ostream *sstream = (struct ssl_ostream *)stream;
struct istream *ssl_input = sstream->ssl_io->ssl_input;

openssl_iostream_shutdown(sstream->ssl_io);
sstream->ssl_io->ssl_output = NULL;
i_stream_unref(&ssl_input);
ssl_iostream_unref(&sstream->ssl_io);
Expand Down

0 comments on commit 6c7efd9

Please sign in to comment.