]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-compression: istream-lz4 - Try again if no data was decompressed
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 23 Feb 2026 12:09:02 +0000 (14:09 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 24 Feb 2026 08:36:15 +0000 (08:36 +0000)
src/lib-compression/istream-lz4.c
src/lib-compression/test-compression.c

index f36390629362518d1bad41ab7888a6b0a83d7af0..6fb69ef5f028760a1a14f263cd83e4a8cf0e2256 100644 (file)
@@ -205,7 +205,8 @@ static ssize_t i_stream_lz4_read(struct istream_private *stream)
                lz4_read_error(zstream, "corrupted lz4 chunk");
                stream->istream.stream_errno = EINVAL;
                return -1;
-       }
+       } else if (ret == 0)
+               return i_stream_lz4_read(stream);
        i_assert(ret > 0);
        stream->pos += ret;
        i_assert(stream->pos <= stream->buffer_size);
index dad332331ce5dde7aea6e1ce3d10bf954f9a63bf..105a47a43511a8022968ab63196db8372b916fb0 100644 (file)
@@ -1014,6 +1014,11 @@ static const unsigned char lz4_chunk_crash_02[] = {
         0x32, 0x01, 0xff, 0xff, 0x00, 0x30
 };
 
+static const unsigned char lz4_chunk_eof_03[] = {
+       0x44, 0x6f, 0x76, 0x65, 0x63, 0x6f, 0x74, 0x2d, 0x4c, 0x5a, 0x34, 0x0d,
+       0x2a, 0x9b, 0xc5, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+};
+
 static void test_lz4_chunk_size(void)
 {
        const struct compression_handler *lz4;
@@ -1050,6 +1055,18 @@ static void test_lz4_chunk_size(void)
 
        i_stream_unref(&input);
 
+       file_input = test_istream_create_data(lz4_chunk_eof_03,
+                                             sizeof(lz4_chunk_eof_03));
+       input = lz4->create_istream(file_input);
+       i_stream_unref(&file_input);
+       i_stream_read(input);
+
+       /* no error, but no content either */
+       test_assert(input->eof);
+       test_assert(input->stream_errno == 0);
+
+       i_stream_unref(&input);
+
        test_end();
 }