]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Handle buggy OpenSSL error handling without assert-crash
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Jan 2020 14:06:39 +0000 (16:06 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 27 Feb 2020 11:10:07 +0000 (11:10 +0000)
If OpenSSL returns a syscall failure but provides no error and doesn't set
errno, log it as an OpenSSL bug instead of assert-crashing.

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

index 5b2d8c7a8a82cd55ea3e8de1c6f0d3af85821c2d..ad605712a0461ca1127d73176843bd30a56eeb89 100644 (file)
@@ -595,14 +595,16 @@ int openssl_iostream_handle_error(struct ssl_iostream *ssl_io, int ret,
                if (ERR_peek_error() != 0) {
                        errstr = openssl_iostream_error();
                        errno = EINVAL;
-               } else if (ret != 0) {
-                       i_assert(errno != 0);
-                       errstr = strerror(errno);
-               } else {
+               } else if (ret == 0) {
                        /* EOF. */
                        errno = EPIPE;
                        errstr = "Disconnected";
                        break;
+               } else if (errno != 0) {
+                       errstr = strerror(errno);
+               } else {
+                       /* Seen this at least with v1.1.0l SSL_accept() */
+                       errstr = "OpenSSL BUG: errno=0";
                }
                errstr = t_strdup_printf("%s syscall failed: %s",
                                         func_name, errstr);