Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9176:fcebba0f438f HEAD
zlib: Fixed error handling.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 27 Jun 2009 22:25:35 -0400 |
parents | e67c9b3e88b0 |
children | 8faf1cc19bd7 |
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 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"
--- 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;