dovecot-1.2: zlib: Fixed error handling.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jun 28 05:25:40 EEST 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/fcebba0f438f
changeset: 9176:fcebba0f438f
user: Timo Sirainen <tss at iki.fi>
date: Sat Jun 27 22:25:35 2009 -0400
description:
zlib: Fixed error handling.
diffstat:
2 files changed, 10 insertions(+), 1 deletion(-)
src/plugins/zlib/istream-bzlib.c | 2 ++
src/plugins/zlib/istream-zlib.c | 9 ++++++++-
diffs (38 lines):
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 @@ static ssize_t i_stream_zlib_read(struct
{
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 @@ static ssize_t i_stream_zlib_read(struct
}
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;
More information about the dovecot-cvs
mailing list