]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: client-common-auth - Centralize calling client_auth_respond() to client...
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sat, 7 Oct 2023 23:16:00 +0000 (01:16 +0200)
committerstephan.bosch <stephan.bosch@open-xchange.com>
Mon, 23 Oct 2023 15:50:54 +0000 (15:50 +0000)
This makes sure the auth response data is always cleared after.

src/login-common/client-common-auth.c
src/login-common/client-common.h

index f5696e98f676dda291de93e8fa7f4075dd863d3f..cdbf037d47af4d78637b409a3a88ac57b9f2a8a4 100644 (file)
@@ -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)
index e910c8a4c16da5e0bab18fe068c2c9d1fa218d2e..a1630155a1e5cb69e149a7197937960637690e10 100644 (file)
@@ -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,