From: Stephan Bosch Date: Fri, 9 Feb 2018 16:24:28 +0000 (+0100) Subject: lib-ssl-iostream: ostream-openssl: Fix behavior of o_stream_flush() so that 1 is... X-Git-Tag: 2.3.9~2302 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=092762029d2fd162283c1df6a40ddc1019605798;p=thirdparty%2Fdovecot%2Fcore.git lib-ssl-iostream: ostream-openssl: Fix behavior of o_stream_flush() so that 1 is only returned when buffer is empty. --- 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