]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Error handling fix.
authorTimo Sirainen <tss@iki.fi>
Thu, 3 Apr 2014 09:50:43 +0000 (12:50 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 3 Apr 2014 09:50:43 +0000 (12:50 +0300)
Don't set last_error="(null)" when the connection was simply disconnected.

src/lib-ssl-iostream/istream-openssl.c

index 79e16af926ff821e6cf5b50710592c2e7fd97dae..7a16253e391643c514a027d59f9a8beebe4a601c 100644 (file)
@@ -71,14 +71,16 @@ static ssize_t i_stream_ssl_read_real(struct istream_private *stream)
                /* failed to read anything */
                ret = openssl_iostream_handle_error(ssl_io, ret, "SSL_read");
                if (ret <= 0) {
-                       if (ret < 0) {
+                       if (ret == 0)
+                               return 0;
+                       if (ssl_io->last_error != NULL) {
                                io_stream_set_error(&stream->iostream,
                                                    "%s", ssl_io->last_error);
-                               stream->istream.stream_errno = errno;
-                               stream->istream.eof = TRUE;
-                               sstream->seen_eof = TRUE;
                        }
-                       return ret;
+                       stream->istream.stream_errno = errno;
+                       stream->istream.eof = TRUE;
+                       sstream->seen_eof = TRUE;
+                       return -1;
                }
                /* we did some BIO I/O, try reading again */
        }