[dovecot-cvs] dovecot/src/imap-login client.c,1.20,1.21

cras at procontrol.fi cras at procontrol.fi
Thu Oct 16 19:56:22 EEST 2003


Update of /home/cvs/dovecot/src/imap-login
In directory danu:/tmp/cvs-serv3263

Modified Files:
	client.c 
Log Message:
Don't disconnect client immediately if there's an error in IMAP syntax.



Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap-login/client.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- client.c	21 Sep 2003 16:21:37 -0000	1.20
+++ client.c	16 Oct 2003 15:56:20 -0000	1.21
@@ -187,6 +187,8 @@
 static int client_handle_input(struct imap_client *client)
 {
 	struct imap_arg *args;
+	const char *msg;
+	int fatal;
 
 	if (client->authenticating)
 		return FALSE; /* wait until authentication is finished */
@@ -224,8 +226,19 @@
 	switch (imap_parser_read_args(client->parser, 0, 0, &args)) {
 	case -1:
 		/* error */
-		client_destroy(client, NULL);
-		return FALSE;
+		msg = imap_parser_get_error(client->parser, &fatal);
+		if (fatal) {
+			client_send_line(client, t_strconcat("* BYE ",
+							     msg, NULL));
+			client_destroy(client, t_strconcat("Disconnected: ",
+							   msg, NULL));
+			return FALSE;
+		}
+
+		client_send_tagline(client, t_strconcat("BAD ", msg, NULL));
+		client->cmd_finished = TRUE;
+		client->skip_line = TRUE;
+		return TRUE;
 	case -2:
 		/* not enough data */
 		return FALSE;
@@ -234,6 +247,8 @@
 
 	if (*client->cmd_tag == '\0' ||
 	    !client_command_execute(client, client->cmd_name, args)) {
+		if (*client->cmd_tag == '\0')
+			client->cmd_tag = "*";
 		if (++client->bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
 			client_send_line(client,
 				"* BYE Too many invalid IMAP commands.");



More information about the dovecot-cvs mailing list