From: Timo Sirainen Date: Thu, 19 Sep 2013 21:14:11 +0000 (+0300) Subject: istream-file: Assert-crash if read() fails with EBADF. X-Git-Tag: 2.2.6~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f131c8b6d88ffc65d94eae63e0b3c11d7c24cb9;p=thirdparty%2Fdovecot%2Fcore.git istream-file: Assert-crash if read() fails with EBADF. Something's already wrong at that point and it may not be safe to continue. Also crashing makes it easier to debug such situation. --- diff --git a/src/lib/istream-file.c b/src/lib/istream-file.c index 2d04106e85..c4dabd5402 100644 --- a/src/lib/istream-file.c +++ b/src/lib/istream-file.c @@ -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; }