]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Shutdown connection cleanly whenever i/ostream is destroyed
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 6 Jul 2018 08:25:07 +0000 (11:25 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 9 Jul 2018 07:40:12 +0000 (10:40 +0300)
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.

src/lib-ssl-iostream/istream-openssl.c
src/lib-ssl-iostream/ostream-openssl.c

index 3bdfdb17ccc6ce163566c1f29bcf5381ad598f47..d23efd0a99fc5c6e63a5a65db629ef42d428aeb0 100644 (file)
@@ -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);
index e6e8aa5686d5febc9c2c4ff665e935f759831c18..d1518bc5d7264115b90d9acb14e171e836e985e2 100644 (file)
@@ -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);