[dovecot-cvs] dovecot/src/login client.c,1.28,1.29 client.h,1.12,1.13

cras at procontrol.fi cras at procontrol.fi
Tue Jan 21 13:17:46 EET 2003


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

Modified Files:
	client.c client.h 
Log Message:
imap-login: disconnect when received 10 invalid commands. imap: disconnect
when received 20 invalid commands in a row - every successful command resets
the counter now.



Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/client.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- client.c	11 Jan 2003 15:29:47 -0000	1.28
+++ client.c	21 Jan 2003 11:17:44 -0000	1.29
@@ -24,6 +24,9 @@
 /* Disconnect client after idling this many seconds */
 #define CLIENT_LOGIN_IDLE_TIMEOUT 60
 
+/* Disconnect client when it sends too many bad commands */
+#define CLIENT_MAX_BAD_COMMANDS 10
+
 /* When max. number of simultaneous connections is reached, few of the
    oldest connections are disconnected. Since we have to go through the whole
    client hash, it's faster if we disconnect multiple clients. */
@@ -210,6 +213,13 @@
 
 	if (*client->cmd_tag == '\0' ||
 	    !client_command_execute(client, client->cmd_name, args)) {
+		if (++client->bad_counter >= CLIENT_MAX_BAD_COMMANDS) {
+			client_send_line(client,
+				"* BYE Too many invalid IMAP commands.");
+			client_destroy(client, "Disconnected: "
+				       "Too many invalid commands");
+			return;
+		} 
 		client_send_tagline(client,
 			"BAD Error in IMAP command received by server.");
 	}

Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/client.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- client.h	9 Jan 2003 12:19:07 -0000	1.12
+++ client.h	21 Jan 2003 11:17:44 -0000	1.13
@@ -15,6 +15,8 @@
 	struct imap_parser *parser;
 
 	time_t last_input;
+	unsigned int bad_counter;
+
 	const char *cmd_tag, *cmd_name;
 
 	buffer_t *plain_login;




More information about the dovecot-cvs mailing list