dovecot-2.0: zlib: Fixed reading concatenated .gz files.

dovecot at dovecot.org dovecot at dovecot.org
Tue Aug 23 21:41:36 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/35e4a547231c
changeset: 12881:35e4a547231c
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Aug 23 21:41:24 2011 +0300
description:
zlib: Fixed reading concatenated .gz files.

diffstat:

 src/plugins/zlib/istream-zlib.c |  18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diffs (45 lines):

diff -r 39655869f2ee -r 35e4a547231c src/plugins/zlib/istream-zlib.c
--- a/src/plugins/zlib/istream-zlib.c	Tue Aug 23 21:20:13 2011 +0300
+++ b/src/plugins/zlib/istream-zlib.c	Tue Aug 23 21:41:24 2011 +0300
@@ -38,6 +38,8 @@
 	unsigned int zs_closed:1;
 };
 
+static void i_stream_zlib_init(struct zlib_istream *zstream);
+
 static void i_stream_zlib_close(struct iostream_private *stream)
 {
 	struct zlib_istream *zstream = (struct zlib_istream *)stream;
@@ -157,6 +159,7 @@
 		return -1;
 	}
 	i_stream_skip(stream->parent, GZ_TRAILER_SIZE);
+	zstream->prev_size = 0;
 	zstream->trailer_read = TRUE;
 	return 1;
 }
@@ -180,12 +183,21 @@
 			if (ret <= 0)
 				return ret;
 		}
-		stream->istream.eof = TRUE;
-		return -1;
+		if (!zstream->gz || i_stream_is_eof(stream->parent)) {
+			stream->istream.eof = TRUE;
+			return -1;
+		}
+		/* gzip file with concatenated content */
+		zstream->eof_offset = (uoff_t)-1;
+		zstream->header_read = FALSE;
+		zstream->trailer_read = FALSE;
+		zstream->crc32 = 0;
+
+		(void)inflateEnd(&zstream->zs);
+		i_stream_zlib_init(zstream);
 	}
 
 	if (!zstream->header_read) {
-		i_assert(zstream->high_pos == 0);
 		do {
 			ret = i_stream_zlib_read_header(stream);
 		} while (ret == 0 && stream->istream.blocking);


More information about the dovecot-cvs mailing list