From 6d4e1c7ab69247faf3bf270707ad8482abc5978a Mon Sep 17 00:00:00 2001 From: Stephan Bosch Date: Fri, 9 Feb 2018 17:24:28 +0100 Subject: [PATCH] lib-ssl-iostream: ostream-openssl: Fix behavior of o_stream_flush() so that 1 is only returned when buffer is empty. --- src/lib-ssl-iostream/ostream-openssl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib-ssl-iostream/ostream-openssl.c b/src/lib-ssl-iostream/ostream-openssl.c index 44b06201cf..138e6626cd 100644 --- a/src/lib-ssl-iostream/ostream-openssl.c +++ b/src/lib-ssl-iostream/ostream-openssl.c @@ -138,7 +138,13 @@ static int o_stream_ssl_flush(struct ostream_private *stream) sstream->ssl_io->ostream_flush_waiting_input = TRUE; ret = 1; } - return ret; + + if (ret <= 0) + return ret; + + /* return 1 only when the output buffer is empty, which is what the + caller expects. */ + return o_stream_get_buffer_used_size(plain_output) == 0 ? 1 : 0; } static ssize_t