Skip to content

Commit

Permalink
lib-dcrypt: Don't finalize encryption on o_stream_flush()
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
sirainen committed Sep 21, 2016
1 parent 946de45 commit bfed4b1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lib-dcrypt/ostream-encrypt.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit bfed4b1

Please sign in to comment.