From: Timo Sirainen Date: Tue, 20 Sep 2016 15:08:10 +0000 (+0300) Subject: lib-dcrypt: Don't finalize encryption on o_stream_flush() X-Git-Tag: 2.3.0.rc1~2993 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2edbc51be62d7da4a4b37a72f9832851f669caa;p=thirdparty%2Fdovecot%2Fcore.git lib-dcrypt: Don't finalize encryption on o_stream_flush() For example the default o_stream_uncork() implementation enforces flushing and it's probably better not to change that. In general there's really no reason to perform the finalization at flush when the stream can't be written to anymore (whereas lib-compression ostreams allow writes after flushes). --- diff --git a/src/lib-dcrypt/ostream-encrypt.c b/src/lib-dcrypt/ostream-encrypt.c index ae661a9e73..dbc0afadb0 100644 --- a/src/lib-dcrypt/ostream-encrypt.c +++ b/src/lib-dcrypt/ostream-encrypt.c @@ -484,7 +484,7 @@ ssize_t o_stream_encrypt_sendv(struct ostream_private *stream, } static -int o_stream_encrypt_flush(struct ostream_private *stream) +int o_stream_encrypt_finalize(struct ostream_private *stream) { const char *error; struct encrypt_ostream *estream = (struct encrypt_ostream *)stream; @@ -545,7 +545,7 @@ void o_stream_encrypt_close(struct iostream_private *stream, struct encrypt_ostream *estream = (struct encrypt_ostream *)stream; if (estream->ctx_sym != NULL && !estream->finalized && estream->ostream.ostream.stream_errno == 0) - o_stream_encrypt_flush(&estream->ostream); + o_stream_encrypt_finalize(&estream->ostream); if (close_parent) { o_stream_close(estream->ostream.parent); } @@ -629,7 +629,6 @@ o_stream_create_encrypt_common(enum io_stream_encrypt_flags flags) estream = i_new(struct encrypt_ostream, 1); estream->ostream.sendv = o_stream_encrypt_sendv; - estream->ostream.flush = o_stream_encrypt_flush; estream->ostream.iostream.close = o_stream_encrypt_close; estream->ostream.iostream.destroy = o_stream_encrypt_destroy;