]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Don't try to flush SSL output if SSL handshake fails.
authorTimo Sirainen <tss@iki.fi>
Tue, 28 Apr 2015 09:27:04 +0000 (11:27 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 28 Apr 2015 09:27:04 +0000 (11:27 +0200)
This fixes a crash on failed handshakes on some OpenSSL builds.

src/login-common/ssl-proxy-openssl.c

index 40bbbcab1a2da684d9a886ef8f19323a0d6e1495..cf6a36a62c116fccfd6414b7de059ddbb7928727 100644 (file)
@@ -80,6 +80,7 @@ struct ssl_proxy {
        unsigned int cert_broken:1;
        unsigned int client_proxy:1;
        unsigned int flushing:1;
+       unsigned int failed:1;
 };
 
 struct ssl_parameters {
@@ -131,6 +132,12 @@ static void ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx,
 static int ssl_proxy_ctx_get_pkey_ec_curve_name(const struct master_service_ssl_settings *set);
 #endif
 
+static void ssl_proxy_destroy_failed(struct ssl_proxy *proxy)
+{
+       proxy->failed = TRUE;
+       ssl_proxy_destroy(proxy);
+}
+
 static unsigned int ssl_server_context_hash(const struct ssl_server_context *ctx)
 {
        unsigned int i, g, h = 0;
@@ -462,7 +469,7 @@ static void ssl_handle_error(struct ssl_proxy *proxy, int ret,
 
        if (errstr != NULL) {
                proxy->last_error = i_strdup(errstr);
-               ssl_proxy_destroy(proxy);
+               ssl_proxy_destroy_failed(proxy);
        }
        ssl_proxy_unref(proxy);
 }
@@ -492,7 +499,7 @@ static void ssl_handshake(struct ssl_proxy *proxy)
 
        if (proxy->handshake_callback != NULL) {
                if (proxy->handshake_callback(proxy->handshake_context) < 0)
-                       ssl_proxy_destroy(proxy);
+                       ssl_proxy_destroy_failed(proxy);
        }
 }
 
@@ -822,7 +829,8 @@ void ssl_proxy_destroy(struct ssl_proxy *proxy)
        if (proxy->destroyed || proxy->flushing)
                return;
        proxy->flushing = TRUE;
-       ssl_proxy_flush(proxy);
+       if (!proxy->failed && proxy->handshaked)
+               ssl_proxy_flush(proxy);
        proxy->destroyed = TRUE;
 
        ssl_proxy_count--;