]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-compress: lz4 istream wasn't detected reliably in some situations.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 16 Dec 2015 13:06:52 +0000 (15:06 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 16 Dec 2015 13:06:52 +0000 (15:06 +0200)
We requested too few bytes from istream, so there wasn't any guarantee that
the istream actually had all the bytes. This caused a problem for example
with mdbox when the previous mail was already fetched and the stream happened
to end in the middle of the lz4 header.

src/lib-compression/compression.c

index c0c13a26db24f646f787aab5378e42fbeab84945..e79a0f84fbf15b150d1d8a025b013a08d6f22563 100644 (file)
@@ -73,7 +73,8 @@ static bool is_compressed_lz4(struct istream *input)
        const unsigned char *data;
        size_t size;
 
-       if (i_stream_read_data(input, &data, &size, 6 - 1) <= 0)
+       if (i_stream_read_data(input, &data, &size,
+                              IOSTREAM_LZ4_MAGIC_LEN - 1) <= 0)
                return FALSE;
        /* there is no standard LZ4 header, so we've created our own */
        return memcmp(data, IOSTREAM_LZ4_MAGIC, IOSTREAM_LZ4_MAGIC_LEN) == 0;