}
}
-int cmd_auth(struct pop3_client *pop3_client, bool *parsed_r)
+int cmd_auth(struct pop3_client *pop3_client)
{
/* NOTE: This command's input is handled specially because the
SASL-IR can be large. */
size_t i, size;
int ret;
- *parsed_r = FALSE;
-
/* <auth mechanism name> [<initial SASL response>] */
if (!pop3_client->auth_mech_name_parsed) {
data = i_stream_get_data(client->input, &size);
client_send_raw(client, "\r\n");
}
client_send_raw(client, ".\r\n");
- *parsed_r = TRUE;
(void)i_stream_read_next_line(client->input);
return 1;
}
i_stream_skip(client->input, i);
}
- client->authenticating = TRUE;
/* get SASL-IR, if any */
if ((ret = client_auth_read_line(client)) <= 0)
return ret;
if (client->auth_response->used > 0)
ir = t_strdup(str_c(client->auth_response));
- *parsed_r = TRUE;
pop3_client->auth_mech_name_parsed = FALSE;
return client_auth_begin(client, t_strdup(client->auth_mech_name), ir);
}
bool cmd_capa(struct pop3_client *client, const char *args);
bool cmd_user(struct pop3_client *client, const char *args);
bool cmd_pass(struct pop3_client *client, const char *args);
-int cmd_auth(struct pop3_client *client, bool *parsed_r);
+int cmd_auth(struct pop3_client *client);
bool cmd_apop(struct pop3_client *client, const char *args);
#endif
static void pop3_client_input(struct client *client)
{
- if (client->authenticating) {
- struct pop3_client *pop3_client =
- container_of(client, struct pop3_client, common);
- bool parsed;
- cmd_auth(pop3_client, &parsed);
- if (!parsed)
- client->authenticating = FALSE;
- else
- return;
- }
+ i_assert(!client->authenticating);
if (!client_read(client))
return;
{
struct pop3_client *pop3_client = (struct pop3_client *)client;
const char *cmd, *args;
- bool parsed;
- if (!client_read_cmd_name(client, &cmd))
- return FALSE;
+ if (pop3_client->current_cmd == NULL) {
+ if (!client_read_cmd_name(client, &cmd))
+ return FALSE;
+ pop3_client->current_cmd = i_strdup(cmd);
+ }
- if (strcmp(cmd, "AUTH") == 0) {
- int ret = cmd_auth(pop3_client, &parsed);
- if (ret == 0 || !parsed)
+ if (strcmp(pop3_client->current_cmd, "AUTH") == 0) {
+ if (cmd_auth(pop3_client) <= 0) {
+ /* Need more input / destroyed. We also get here when
+ SASL authentication is actually started. */
return FALSE;
- return parsed;
+ }
+ /* AUTH command finished already (SASL probe or ERR reply) */
+ i_free(pop3_client->current_cmd);
+ return TRUE;
}
if ((args = i_stream_next_line(client->input)) == NULL)
return FALSE;
- if (client_command_execute(pop3_client, cmd, args))
+ if (client_command_execute(pop3_client, pop3_client->current_cmd, args))
client->bad_counter = 0;
else if (++client->bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
client_send_reply(client, POP3_CMD_REPLY_ERROR,
"Disconnected: Too many bad commands");
return FALSE;
}
+ i_free(pop3_client->current_cmd);
return TRUE;
}
{
struct pop3_client *pop3_client = (struct pop3_client *)client;
+ i_free_and_null(pop3_client->current_cmd);
i_free_and_null(pop3_client->last_user);
i_free_and_null(pop3_client->apop_challenge);
}