changeset 19519:7de67ada80b3

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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 16 Dec 2015 15:06:52 +0200
parents f1ec963e9436
children 05ba8c869fb7
files src/lib-compression/compression.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-compression/compression.c	Wed Dec 16 14:11:04 2015 +0200
+++ b/src/lib-compression/compression.c	Wed Dec 16 15:06:52 2015 +0200
@@ -73,7 +73,8 @@
 	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;