]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-compression: istream-lzma - Improve error messages in EOF handling
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 9 Sep 2020 09:48:39 +0000 (12:48 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 10 Sep 2020 13:52:25 +0000 (13:52 +0000)
src/lib-compression/istream-lzma.c

index 7bc02d99a38569de3c3a37d868e6b8494d3f2330..6a6bb32b9082601239ad08e3b183fe515a15fa1b 100644 (file)
@@ -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;