From: Timo Sirainen Date: Wed, 9 Sep 2020 09:48:39 +0000 (+0300) Subject: lib-compression: istream-lzma - Improve error messages in EOF handling X-Git-Tag: 2.3.13~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d559f587677377a34c1f32d321719aa4838cf7a8;p=thirdparty%2Fdovecot%2Fcore.git lib-compression: istream-lzma - Improve error messages in EOF handling --- diff --git a/src/lib-compression/istream-lzma.c b/src/lib-compression/istream-lzma.c index 7bc02d99a3..6a6bb32b90 100644 --- a/src/lib-compression/istream-lzma.c +++ b/src/lib-compression/istream-lzma.c @@ -119,10 +119,15 @@ static ssize_t i_stream_lzma_read(struct istream_private *stream) i_assert(stream->parent->eof); lzma_stream_end(zstream); ret = lzma_code(&zstream->strm, LZMA_FINISH); - if (ret != LZMA_STREAM_END) - if (lzma_handle_error(zstream, ret) == 0) - stream->istream.stream_errno = - zstream->hdr_read ? EPIPE : EINVAL; + if (lzma_handle_error(zstream, ret) < 0) + ; + else if (!zstream->hdr_read) { + lzma_read_error(zstream, "file too small (not xz file?)"); + stream->istream.stream_errno = EINVAL; + } else if (ret != LZMA_STREAM_END) { + lzma_read_error(zstream, "unexpected EOF"); + stream->istream.stream_errno = EPIPE; + } stream->istream.eof = TRUE; } return -1;