# HG changeset patch # User Timo Sirainen # Date 1246155935 14400 # Node ID fcebba0f438fd923ed82ffcb818c6bc8e1573f94 # Parent e67c9b3e88b09601f34a21ee18639f8c11199f95 zlib: Fixed error handling. diff -r e67c9b3e88b0 -r fcebba0f438f src/plugins/zlib/istream-bzlib.c --- a/src/plugins/zlib/istream-bzlib.c Sat Jun 27 22:16:49 2009 -0400 +++ b/src/plugins/zlib/istream-bzlib.c Sat Jun 27 22:25:35 2009 -0400 @@ -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 -r e67c9b3e88b0 -r fcebba0f438f src/plugins/zlib/istream-zlib.c --- a/src/plugins/zlib/istream-zlib.c Sat Jun 27 22:16:49 2009 -0400 +++ b/src/plugins/zlib/istream-zlib.c Sat Jun 27 22:25:35 2009 -0400 @@ -58,7 +58,8 @@ { 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) { @@ -100,6 +101,12 @@ } 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;