]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH] 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)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
Gbp-Pq: Name 0001-lib-compression-istream-lz4-Try-again-if-no-data-was.patch

src/lib-compression/istream-lz4.c
src/lib-compression/test-compression.c

index b59604c5b44623115480db2b90e0ec34218b34f0..ee2ddbba716a8fc9008410b37dcaab53d7bf956e 100644 (file)
@@ -198,7 +198,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 1f9b6b9c10905a59492e9442a34cadc1165930e9..7b3e33980b4e91e5ce4aef01645b1ca4d463758e 100644 (file)
@@ -1052,6 +1052,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;
@@ -1088,6 +1093,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();
 }