From: Stephan Bosch Date: Sat, 7 Oct 2023 23:16:00 +0000 (+0200) Subject: login-common: client-common-auth - Centralize calling client_auth_respond() to client... X-Git-Tag: 2.4.0~2493 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c4b69a48b65d3bbe8fc43c57b6dc82c712d923e;p=thirdparty%2Fdovecot%2Fcore.git login-common: client-common-auth - Centralize calling client_auth_respond() to client_auth_input This makes sure the auth response data is always cleared after. --- diff --git a/src/login-common/client-common-auth.c b/src/login-common/client-common-auth.c index f5696e98f6..cdbf037d47 100644 --- a/src/login-common/client-common-auth.c +++ b/src/login-common/client-common-auth.c @@ -864,20 +864,22 @@ int client_auth_read_line(struct client *client) return i < size ? 1 : 0; } -void client_auth_parse_response(struct client *client) +bool client_auth_parse_response(struct client *client) { if (client_auth_read_line(client) <= 0) - return; - - client_auth_respond(client, str_c(client->auth_response)); - memset(str_c_modifiable(client->auth_response), 0, - str_len(client->auth_response)); + return FALSE; + return TRUE; } static void client_auth_input(struct client *client) { i_assert(client->v.auth_parse_response != NULL); - client->v.auth_parse_response(client); + if (!client->v.auth_parse_response(client)) + return; + + client_auth_respond(client, str_c(client->auth_response)); + memset(str_c_modifiable(client->auth_response), 0, + str_len(client->auth_response)); } void client_auth_send_challenge(struct client *client, const char *data) diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index e910c8a4c1..a1630155a1 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -131,7 +131,7 @@ struct client_vfuncs { struct auth_mech_desc *mech); bool (*sasl_check_login)(struct client *client); void (*auth_send_challenge)(struct client *client, const char *data); - void (*auth_parse_response)(struct client *client); + bool (*auth_parse_response)(struct client *client); void (*auth_result)(struct client *client, enum client_auth_result result, const struct client_auth_reply *reply, @@ -379,7 +379,7 @@ void client_common_proxy_failed(struct client *client, void client_set_auth_waiting(struct client *client); void client_auth_send_challenge(struct client *client, const char *data); -void client_auth_parse_response(struct client *client); +bool client_auth_parse_response(struct client *client); int client_auth_begin(struct client *client, const char *mech_name, const char *init_resp); int client_auth_begin_private(struct client *client, const char *mech_name,