Mercurial > dovecot > original-hg > dovecot-1.1
changeset 8316:2f9d957332b6 HEAD
zlib: Fixed error handling.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 27 Jun 2009 22:25:24 -0400 |
parents | 9d337f24fd0e |
children | c4b32e6b9fb0 |
files | src/plugins/zlib/istream-bzlib.c src/plugins/zlib/istream-zlib.c |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/zlib/istream-bzlib.c Wed Jun 24 16:54:06 2009 -0400 +++ b/src/plugins/zlib/istream-bzlib.c Sat Jun 27 22:25:24 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"
--- a/src/plugins/zlib/istream-zlib.c Wed Jun 24 16:54:06 2009 -0400 +++ b/src/plugins/zlib/istream-zlib.c Sat Jun 27 22:25:24 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;