From: Timo Sirainen Date: Tue, 30 Jun 2015 09:18:08 +0000 (+0300) Subject: istream filters: If parent's i_stream_stat() fails, copy the stream_errno. X-Git-Tag: 2.2.19.rc1~298 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c0f1cb7a0564d48ec43c7315ea46ea38d2abd19;p=thirdparty%2Fdovecot%2Fcore.git istream filters: If parent's i_stream_stat() fails, copy the stream_errno. This doesn't actually change any functionality yet, since most i_stream_stat() callers aren't using i_stream_get_error(). --- diff --git a/src/lib-compression/istream-bzlib.c b/src/lib-compression/istream-bzlib.c index eedc0a628e..109520252b 100644 --- a/src/lib-compression/istream-bzlib.c +++ b/src/lib-compression/istream-bzlib.c @@ -266,8 +266,10 @@ i_stream_bzlib_stat(struct istream_private *stream, bool exact) const struct stat *st; size_t size; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; /* when exact=FALSE always return the parent stat's size, even if we diff --git a/src/lib-compression/istream-lz4.c b/src/lib-compression/istream-lz4.c index 8375870396..7e16239ab2 100644 --- a/src/lib-compression/istream-lz4.c +++ b/src/lib-compression/istream-lz4.c @@ -249,8 +249,10 @@ i_stream_lz4_stat(struct istream_private *stream, bool exact) const struct stat *st; size_t size; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; /* when exact=FALSE always return the parent stat's size, even if we diff --git a/src/lib-compression/istream-lzma.c b/src/lib-compression/istream-lzma.c index 98fbb5f214..31db0d1339 100644 --- a/src/lib-compression/istream-lzma.c +++ b/src/lib-compression/istream-lzma.c @@ -275,8 +275,10 @@ i_stream_lzma_stat(struct istream_private *stream, bool exact) const struct stat *st; size_t size; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; /* when exact=FALSE always return the parent stat's size, even if we diff --git a/src/lib-compression/istream-zlib.c b/src/lib-compression/istream-zlib.c index 7b0a96ce51..a37361ce57 100644 --- a/src/lib-compression/istream-zlib.c +++ b/src/lib-compression/istream-zlib.c @@ -417,8 +417,10 @@ i_stream_zlib_stat(struct istream_private *stream, bool exact) const struct stat *st; size_t size; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; /* when exact=FALSE always return the parent stat's size, even if we diff --git a/src/lib-fs/istream-metawrap.c b/src/lib-fs/istream-metawrap.c index b36d28749a..93636a022f 100644 --- a/src/lib-fs/istream-metawrap.c +++ b/src/lib-fs/istream-metawrap.c @@ -92,8 +92,10 @@ static int i_stream_metawrap_stat(struct istream_private *stream, bool exact) const struct stat *st; int ret; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; if (mstream->in_metadata) { diff --git a/src/lib-mail/istream-header-filter.c b/src/lib-mail/istream-header-filter.c index d483a73fbe..7f6b859500 100644 --- a/src/lib-mail/istream-header-filter.c +++ b/src/lib-mail/istream-header-filter.c @@ -505,8 +505,10 @@ i_stream_header_filter_stat(struct istream_private *stream, bool exact) const struct stat *st; uoff_t old_offset; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; if (stream->statbuf.st_size == -1 || !exact) return 0; diff --git a/src/lib-storage/index/mbox/istream-raw-mbox.c b/src/lib-storage/index/mbox/istream-raw-mbox.c index 23c3dc91cc..831f86bc00 100644 --- a/src/lib-storage/index/mbox/istream-raw-mbox.c +++ b/src/lib-storage/index/mbox/istream-raw-mbox.c @@ -417,8 +417,10 @@ i_stream_raw_mbox_stat(struct istream_private *stream, bool exact) const struct stat *st; struct raw_mbox_istream *rstream = (struct raw_mbox_istream *)stream; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; stream->statbuf.st_size = diff --git a/src/lib/istream-limit.c b/src/lib/istream-limit.c index 4f6867e21a..59ef72bb57 100644 --- a/src/lib/istream-limit.c +++ b/src/lib/istream-limit.c @@ -77,8 +77,10 @@ i_stream_limit_stat(struct istream_private *stream, bool exact) struct limit_istream *lstream = (struct limit_istream *) stream; const struct stat *st; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; if (lstream->v_size != (uoff_t)-1) diff --git a/src/lib/istream-sized.c b/src/lib/istream-sized.c index 7dae0ccbad..4cf9e56639 100644 --- a/src/lib/istream-sized.c +++ b/src/lib/istream-sized.c @@ -98,8 +98,10 @@ i_stream_sized_stat(struct istream_private *stream, bool exact ATTR_UNUSED) /* parent stream may be base64-decoder. don't waste time decoding the entire stream, since we already know what the size is supposed to be. */ - if (i_stream_stat(stream->parent, FALSE, &st) < 0) + if (i_stream_stat(stream->parent, FALSE, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; stream->statbuf.st_size = sstream->size; diff --git a/src/lib/istream.c b/src/lib/istream.c index 31c7e77c9b..190c06dfe1 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -767,8 +767,10 @@ i_stream_default_stat(struct istream_private *stream, bool exact) if (stream->parent == NULL) return stream->istream.stream_errno == 0 ? 0 : -1; - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; if (exact && !stream->stream_size_passthrough) { /* exact size is not known, even if parent returned something */ @@ -781,8 +783,10 @@ static int i_stream_default_get_size(struct istream_private *stream, bool exact, uoff_t *size_r) { - if (stream->stat(stream, exact) < 0) + if (stream->stat(stream, exact) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } if (stream->statbuf.st_size == -1) return 0; diff --git a/src/plugins/mail-filter/istream-ext-filter.c b/src/plugins/mail-filter/istream-ext-filter.c index 787fa9d6e8..3cc909babd 100644 --- a/src/plugins/mail-filter/istream-ext-filter.c +++ b/src/plugins/mail-filter/istream-ext-filter.c @@ -135,8 +135,10 @@ i_stream_mail_filter_stat(struct istream_private *stream, bool exact) i_assert(!exact); - if (i_stream_stat(stream->parent, exact, &st) < 0) + if (i_stream_stat(stream->parent, exact, &st) < 0) { + stream->istream.stream_errno = stream->parent->stream_errno; return -1; + } stream->statbuf = *st; return 0; }