From: Timo Sirainen Date: Sun, 28 Jun 2009 02:25:24 +0000 (-0400) Subject: zlib: Fixed error handling. X-Git-Tag: 2.0.alpha1~505 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6c6f4f351c42c2ad5ef96ee48bd4b57cf9bd1490;p=thirdparty%2Fdovecot%2Fcore.git zlib: Fixed error handling. --HG-- branch : HEAD --- diff --git a/src/plugins/zlib/istream-bzlib.c b/src/plugins/zlib/istream-bzlib.c index 49a7b32614..51b0d5e1b6 100644 --- a/src/plugins/zlib/istream-bzlib.c +++ b/src/plugins/zlib/istream-bzlib.c @@ -15,6 +15,8 @@ #define gzclose BZ2_bzclose #define gzread BZ2_bzread #define gzseek BZ2_bzseek +#define gzerror BZ2_bzerror +#define Z_ERRNO BZ_IO_ERROR #define i_stream_create_zlib i_stream_create_bzlib #include "istream-zlib.c" diff --git a/src/plugins/zlib/istream-zlib.c b/src/plugins/zlib/istream-zlib.c index 69f8c3819e..73cd8cba84 100644 --- a/src/plugins/zlib/istream-zlib.c +++ b/src/plugins/zlib/istream-zlib.c @@ -51,7 +51,8 @@ static ssize_t i_stream_zlib_read(struct istream_private *stream) { struct zlib_istream *zstream = (struct zlib_istream *)stream; size_t size; - int ret; + const char *errstr; + int ret, errnum; if (stream->pos == stream->buffer_size) { if (!zstream->marked && stream->skip > 0) { @@ -93,6 +94,12 @@ static ssize_t i_stream_zlib_read(struct istream_private *stream) } if (ret < 0) { + errstr = gzerror(zstream->file, &errnum); + if (errnum != Z_ERRNO) { + i_error("gzread() failed: %s", errstr); + stream->istream.stream_errno = EINVAL; + return -1; + } if (errno == EAGAIN) { i_assert(!stream->istream.blocking); ret = 0;