]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
istream filters: If parent's i_stream_stat() fails, copy the stream_errno.
authorTimo Sirainen <tss@iki.fi>
Tue, 30 Jun 2015 09:18:08 +0000 (12:18 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 30 Jun 2015 09:18:08 +0000 (12:18 +0300)
This doesn't actually change any functionality yet, since most
i_stream_stat() callers aren't using i_stream_get_error().

src/lib-compression/istream-bzlib.c
src/lib-compression/istream-lz4.c
src/lib-compression/istream-lzma.c
src/lib-compression/istream-zlib.c
src/lib-fs/istream-metawrap.c
src/lib-mail/istream-header-filter.c
src/lib-storage/index/mbox/istream-raw-mbox.c
src/lib/istream-limit.c
src/lib/istream-sized.c
src/lib/istream.c
src/plugins/mail-filter/istream-ext-filter.c

index eedc0a628ebd163bbdfed14b669af9f6f4ca2e4b..109520252b43693d768534d8f45c473f7689a45c 100644 (file)
@@ -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
index 8375870396e7dc41095360eac44ace49b5deb511..7e16239ab2d7b74b53f03e3211cc036177eb9bb9 100644 (file)
@@ -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
index 98fbb5f21483674879f6501f28518d164175b954..31db0d1339fa2c36c612267c5c13eade38d2478b 100644 (file)
@@ -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
index 7b0a96ce51868126e999c7d4ca584285b0a15589..a37361ce57f83f709ecf1754aad9d65e916eca2e 100644 (file)
@@ -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
index b36d28749a6557c49ec8d994c64e7aca6089d2cc..93636a022f3049844266b7e170e7956a154a8a79 100644 (file)
@@ -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) {
index d483a73fbef261cd7756795e2f133f0c4a834e99..7f6b859500ccc9b30820634c025d5d0574818ca5 100644 (file)
@@ -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;
index 23c3dc91cca572674935e6dd93c4e98b43dad0c4..831f86bc00bc9796eb90147425086b8ea6c5658c 100644 (file)
@@ -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 =
index 4f6867e21a95589714496b5102722bbd3e7e1be6..59ef72bb57e0ac98a2df39e8e1b5a7d02180e552 100644 (file)
@@ -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)
index 7dae0ccbada515dfb455d2f53fd4a5e7097f5a6d..4cf9e56639360fa7b533e0efba0768d5b5bbb412 100644 (file)
@@ -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;
index 31c7e77c9b8d0510990ac89435fde97aa84f5959..190c06dfe109b792b501885dcf1d5f11ca6b0eac 100644 (file)
@@ -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;
 
index 787fa9d6e8d3efc8dbff9e3f0decd53f3f525586..3cc909babd5bf607f50d60029771ebe8cd774425 100644 (file)
@@ -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;
 }