]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
zlib: Fixed error handling.
authorTimo Sirainen <tss@iki.fi>
Sun, 28 Jun 2009 02:25:24 +0000 (22:25 -0400)
committerTimo Sirainen <tss@iki.fi>
Sun, 28 Jun 2009 02:25:24 +0000 (22:25 -0400)
--HG--
branch : HEAD

src/plugins/zlib/istream-bzlib.c
src/plugins/zlib/istream-zlib.c

index 49a7b32614d590754a1d03aeb785f59aa4daa81e..51b0d5e1b665f5906c267148d01c4fa12c9acf0d 100644 (file)
@@ -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"
index 69f8c3819e39025a45ee5dbac8ecca1281239136..73cd8cba846a4ccab100b8dd1b8e1a1399b533a7 100644 (file)
@@ -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;