]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
istream-file: Assert-crash if read() fails with EBADF.
authorTimo Sirainen <tss@iki.fi>
Thu, 19 Sep 2013 21:14:11 +0000 (00:14 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 19 Sep 2013 21:14:11 +0000 (00:14 +0300)
Something's already wrong at that point and it may not be safe to continue.
Also crashing makes it easier to debug such situation.

src/lib/istream-file.c

index 2d04106e852d7813a1d679bb9271e14a994f1580..c4dabd5402032d1adf821b84958948d83545a74a 100644 (file)
@@ -94,6 +94,9 @@ static ssize_t i_stream_file_read(struct istream_private *stream)
                        ret = 0;
                } else {
                        i_assert(errno != 0);
+                       /* if we get EBADF for a valid fd, it means something's
+                          really wrong and we'd better just crash. */
+                       i_assert(errno != EBADF);
                        stream->istream.stream_errno = errno;
                        return -1;
                }