From b0a354f7a95fed58a071a8d4fd91ec0e331664b7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 4 Jun 2021 11:16:53 +0300 Subject: [PATCH] lib-compression: istream-zstd - Make sure parent stream error isn't overwritten This could have happened if the parent istream failed before the zstd header was read. Practically this didn't happen currently, because the initial parent stream error was normally already handled by istream-decompress before istream-zstd was even called. --- src/lib-compression/istream-zstd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib-compression/istream-zstd.c b/src/lib-compression/istream-zstd.c index 9c9ca4f865..9e059bcffc 100644 --- a/src/lib-compression/istream-zstd.c +++ b/src/lib-compression/istream-zstd.c @@ -146,10 +146,11 @@ static ssize_t i_stream_zstd_read(struct istream_private *stream) stream->istream.stream_errno = stream->parent->stream_errno; stream->istream.eof = stream->parent->eof; - if (!zstream->hdr_read) + if (stream->istream.stream_errno != 0) + ; + else if (!zstream->hdr_read) stream->istream.stream_errno = EINVAL; - else if (zstream->remain && - stream->istream.stream_errno == 0) + else if (zstream->remain) /* truncated data */ stream->istream.stream_errno = EPIPE; return ret; -- 2.47.3