]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Fix assert-crash if client is destroyed during anvil lookup
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 25 Feb 2021 19:58:17 +0000 (21:58 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 12 Mar 2021 10:51:00 +0000 (10:51 +0000)
This could happen if the client gets disconnected due to
"Connection queue full".

Fixes:
Panic: file client-common.c: line 323 (client_destroy): assertion failed: (!client->authenticating)

src/login-common/client-common.c
src/login-common/client-common.h
src/login-common/sasl-server.c

index b2615228ba3f3085552d0f1ddc848462a6b79676..65ce12766bb3bc2770673fa4317e70d2d3f0b3f6 100644 (file)
@@ -24,6 +24,7 @@
 #include "master-service.h"
 #include "master-service-ssl-settings.h"
 #include "master-auth.h"
+#include "anvil-client.h"
 #include "auth-client.h"
 #include "dsasl-client.h"
 #include "login-proxy.h"
@@ -323,6 +324,8 @@ void client_destroy(struct client *client, const char *reason)
        } else if (client->auth_request != NULL) {
                i_assert(client->authenticating);
                sasl_server_auth_abort(client);
+       } else if (client->anvil_query != NULL) {
+               anvil_client_query_abort(anvil, &client->anvil_query);
        } else {
                i_assert(!client->authenticating);
        }
index dbcaee1cc0d75301c63bd9a16d388a6d6bbc7a38..93f9bb7f2bb870a5bd1d855abb4ee11b9e7a6d29 100644 (file)
@@ -193,6 +193,7 @@ struct client {
        time_t auth_first_started, auth_finished;
        const char *sasl_final_resp;
        const char *const *auth_passdb_args;
+       struct anvil_query *anvil_query;
 
        unsigned int master_auth_id;
        unsigned int master_tag;
index d7b6c9db656dd4ac56249fd429589417623c54c0..e4a585c513a69e85fb0d62edfda6172e58fb01d2 100644 (file)
@@ -221,6 +221,8 @@ anvil_lookup_callback(const char *reply, void *context)
        unsigned int conn_count;
        int ret;
 
+       client->anvil_query = NULL;
+
        conn_count = 0;
        if (reply != NULL && str_to_uint(reply, &conn_count) < 0)
                i_fatal("Received invalid reply from anvil: %s", reply);
@@ -270,7 +272,8 @@ anvil_check_too_many_connections(struct client *client,
        query = t_strconcat("LOOKUP\t", login_binary->protocol, "/",
                            net_ip2addr(&client->ip), "/",
                            str_tabescape(client->virtual_user), NULL);
-       anvil_client_query(anvil, query, anvil_lookup_callback, req);
+       client->anvil_query =
+               anvil_client_query(anvil, query, anvil_lookup_callback, req);
 }
 
 static bool