dovecot-2.0-sslstream: *-login: Make sure input isn't being hand...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 13 02:55:35 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0-sslstream/rev/47fdfd49af13
changeset: 10171:47fdfd49af13
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Oct 23 16:19:34 2009 -0400
description:
*-login: Make sure input isn't being handled while not connected to auth process.

diffstat:

3 files changed, 24 insertions(+), 16 deletions(-)
src/imap-login/client.c        |   34 ++++++++++++++++++----------------
src/login-common/sasl-server.c |    2 ++
src/pop3-login/client.c        |    4 ++++

diffs (77 lines):

diff -r ae639ce8cea6 -r 47fdfd49af13 src/imap-login/client.c
--- a/src/imap-login/client.c	Fri Oct 23 16:18:53 2009 -0400
+++ b/src/imap-login/client.c	Fri Oct 23 16:19:34 2009 -0400
@@ -282,22 +282,24 @@ static void imap_client_input(struct cli
 		return;
 
 	client_ref(client);
-
-	if (!auth_client_is_connected(auth_client)) {
-		/* we're not yet connected to auth process -
-		   don't allow any commands */
-		client_send_line(client, CLIENT_CMD_REPLY_STATUS,
-				 AUTH_SERVER_WAITING_MSG);
-		if (client->to_auth_waiting != NULL)
-			timeout_remove(&client->to_auth_waiting);
-
-		client->input_blocked = TRUE;
-	} else {
-		o_stream_cork(imap_client->common.output);
-		while (client_handle_input(imap_client)) ;
-		o_stream_uncork(imap_client->common.output);
-	}
-
+	o_stream_cork(imap_client->common.output);
+	for (;;) {
+		if (!auth_client_is_connected(auth_client)) {
+			/* we're not currently connected to auth process -
+			   don't allow any commands */
+			client_send_line(client, CLIENT_CMD_REPLY_STATUS,
+					 AUTH_SERVER_WAITING_MSG);
+			if (client->to_auth_waiting != NULL)
+				timeout_remove(&client->to_auth_waiting);
+
+			client->input_blocked = TRUE;
+			break;
+		} else {
+			if (!client_handle_input(imap_client))
+				break;
+		}
+	}
+	o_stream_uncork(imap_client->common.output);
 	client_unref(&client);
 }
 
diff -r ae639ce8cea6 -r 47fdfd49af13 src/login-common/sasl-server.c
--- a/src/login-common/sasl-server.c	Fri Oct 23 16:18:53 2009 -0400
+++ b/src/login-common/sasl-server.c	Fri Oct 23 16:19:34 2009 -0400
@@ -247,6 +247,8 @@ void sasl_server_auth_begin(struct clien
 	struct auth_request_info info;
 	const struct auth_mech_desc *mech;
 
+	i_assert(auth_client_is_connected(auth_client));
+
 	client->auth_attempts++;
 	client->authenticating = TRUE;
 	i_free(client->auth_mech_name);
diff -r ae639ce8cea6 -r 47fdfd49af13 src/pop3-login/client.c
--- a/src/pop3-login/client.c	Fri Oct 23 16:18:53 2009 -0400
+++ b/src/pop3-login/client.c	Fri Oct 23 16:19:34 2009 -0400
@@ -82,6 +82,7 @@ static void pop3_client_input(struct cli
 	/* if a command starts an authentication, stop processing further
 	   commands until the authentication is finished. */
 	while (!client->output->closed && !client->authenticating &&
+	       auth_client_is_connected(auth_client) &&
 	       (line = i_stream_next_line(client->input)) != NULL) {
 		args = strchr(line, ' ');
 		if (args != NULL)
@@ -97,6 +98,9 @@ static void pop3_client_input(struct cli
 				       "Disconnected: Too many bad commands");
 		}
 	}
+
+	if (!auth_client_is_connected(auth_client))
+		client->input_blocked = TRUE;
 
 	if (client_unref(&client))
 		o_stream_uncork(client->output);


More information about the dovecot-cvs mailing list