]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Fix clients linked list corruption with SSL connections
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 11 Jan 2018 18:38:14 +0000 (13:38 -0500)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 20 Feb 2018 13:36:19 +0000 (15:36 +0200)
This could have resulted in infinite loops or some of the clients being
skipped for some operations.

src/login-common/client-common.c

index 636af8b0d4b2e8b44eef46263a936976b53026d1..a3c6d7a54cc11ac32d359e3abec138cd6ab9b804 100644 (file)
@@ -261,6 +261,7 @@ void client_disconnect(struct client *client, const char *reason)
                   so don't disconnect the client until client_unref(). */
                if (client->iostream_fd_proxy != NULL) {
                        client->fd_proxying = TRUE;
+                       i_assert(client->prev == NULL && client->next == NULL);
                        DLLIST_PREPEND(&client_fd_proxies, client);
                        client_fd_proxies_count++;
                }
@@ -275,14 +276,16 @@ void client_destroy(struct client *client, const char *reason)
                return;
        client->destroyed = TRUE;
 
-       client_disconnect(client, reason);
-
-       pool_unref(&client->preproxy_pool);
-
        if (last_client == client)
                last_client = client->prev;
+       /* remove from clients linked list before it's added to
+          client_fd_proxies. */
        DLLIST_REMOVE(&clients, client);
 
+       client_disconnect(client, reason);
+
+       pool_unref(&client->preproxy_pool);
+
        if (client->master_tag != 0) {
                i_assert(client->auth_request == NULL);
                i_assert(client->authenticating);