From: Timo Sirainen Date: Fri, 16 Apr 2021 13:13:39 +0000 (+0300) Subject: login-common: Fix memory leak if anvil query is aborted X-Git-Tag: 2.3.15~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c377525cd4e905465d39dd5a4fd174b731f8565;p=thirdparty%2Fdovecot%2Fcore.git login-common: Fix memory leak if anvil query is aborted --- diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index cc1d46826a..2c7c6ee036 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -194,6 +194,7 @@ struct client { const char *sasl_final_resp; const char *const *auth_passdb_args; struct anvil_query *anvil_query; + struct anvil_request *anvil_request; unsigned int master_auth_id; unsigned int master_tag; diff --git a/src/login-common/sasl-server.c b/src/login-common/sasl-server.c index 22688d537f..bfa420943e 100644 --- a/src/login-common/sasl-server.c +++ b/src/login-common/sasl-server.c @@ -223,6 +223,7 @@ anvil_lookup_callback(const char *reply, void *context) int ret; client->anvil_query = NULL; + client->anvil_request = NULL; conn_count = 0; if (reply != NULL && str_to_uint(reply, &conn_count) < 0) @@ -273,6 +274,7 @@ 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); + client->anvil_request = req; client->anvil_query = anvil_client_query(anvil, query, anvil_lookup_callback, req); } @@ -553,7 +555,9 @@ void sasl_server_auth_failed(struct client *client, const char *reason, void sasl_server_auth_abort(struct client *client) { client->auth_try_aborted = TRUE; - if (client->anvil_query != NULL) + if (client->anvil_query != NULL) { anvil_client_query_abort(anvil, &client->anvil_query); + i_free(client->anvil_request); + } sasl_server_auth_cancel(client, NULL, NULL, SASL_SERVER_REPLY_AUTH_ABORTED); }