dovecot-2.1: lib-ssl-iostream: Don't assert-crash if underlying ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 18 13:21:11 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/39d9e75fec02
changeset: 14564:39d9e75fec02
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 18 13:21:03 2012 +0300
description:
lib-ssl-iostream: Don't assert-crash if underlying connection suddenly disconnects.

diffstat:

 src/lib-ssl-iostream/iostream-openssl.c |  7 +++++--
 src/lib-ssl-iostream/istream-openssl.c  |  1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diffs (42 lines):

diff -r 9fc78d06252c -r 39d9e75fec02 src/lib-ssl-iostream/iostream-openssl.c
--- a/src/lib-ssl-iostream/iostream-openssl.c	Mon Jun 18 13:19:41 2012 +0300
+++ b/src/lib-ssl-iostream/iostream-openssl.c	Mon Jun 18 13:21:03 2012 +0300
@@ -388,7 +388,8 @@
 			return 0;
 		}
 		if (ssl_io->closed) {
-			errno = ssl_io->plain_stream_errno;
+			errno = ssl_io->plain_stream_errno != 0 ?
+				ssl_io->plain_stream_errno : EPIPE;
 			return -1;
 		}
 		return 1;
@@ -396,7 +397,8 @@
 		ssl_io->want_read = TRUE;
 		(void)ssl_iostream_bio_sync(ssl_io);
 		if (ssl_io->closed) {
-			errno = ssl_io->plain_stream_errno;
+			errno = ssl_io->plain_stream_errno != 0 ?
+				ssl_io->plain_stream_errno : EPIPE;
 			return -1;
 		}
 		return ssl_io->want_read ? 0 : 1;
@@ -406,6 +408,7 @@
 			errstr = ssl_iostream_error();
 			errno = EINVAL;
 		} else if (ret != 0) {
+			i_assert(errno != 0);
 			errstr = strerror(errno);
 		} else {
 			/* EOF. */
diff -r 9fc78d06252c -r 39d9e75fec02 src/lib-ssl-iostream/istream-openssl.c
--- a/src/lib-ssl-iostream/istream-openssl.c	Mon Jun 18 13:19:41 2012 +0300
+++ b/src/lib-ssl-iostream/istream-openssl.c	Mon Jun 18 13:21:03 2012 +0300
@@ -38,6 +38,7 @@
 	if (ret <= 0) {
 		if (ret < 0) {
 			/* handshake failed */
+			i_assert(errno != 0);
 			stream->istream.stream_errno = errno;
 		}
 		return ret;


More information about the dovecot-cvs mailing list