From: Timo Sirainen Date: Wed, 16 Dec 2015 13:06:52 +0000 (+0200) Subject: lib-compress: lz4 istream wasn't detected reliably in some situations. X-Git-Tag: 2.2.22.rc1~401 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=879dfd4da1a9a379936b8d51c1e00c3bd77873b4;p=thirdparty%2Fdovecot%2Fcore.git lib-compress: lz4 istream wasn't detected reliably in some situations. 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. --- diff --git a/src/lib-compression/compression.c b/src/lib-compression/compression.c index c0c13a26db..e79a0f84fb 100644 --- a/src/lib-compression/compression.c +++ b/src/lib-compression/compression.c @@ -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;