[dovecot-cvs] dovecot/src/imap client.c,1.30,1.31 cmd-append.c,1.26,1.27 common.h,1.7,1.8 main.c,1.35,1.36

cras at procontrol.fi cras at procontrol.fi
Wed Jul 2 04:57:27 EEST 2003


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

Modified Files:
	client.c cmd-append.c common.h main.c 
Log Message:
IMAP parser memory limits are now enforced by bytes per line rather than
limiting maximum amount of tokens per line. Default is 64k now, which should
help with the huge message sets generated by some clients.



Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- client.c	4 Jun 2003 16:35:11 -0000	1.30
+++ client.c	2 Jul 2003 00:57:24 -0000	1.31
@@ -9,9 +9,6 @@
 
 #include <stdlib.h>
 
-/* max. size of one parameter in line */
-#define MAX_INBUF_SIZE 8192
-
 /* If we can't send a buffer in a minute, disconnect the client */
 #define CLIENT_OUTPUT_TIMEOUT (60*1000)
 
@@ -49,7 +46,7 @@
 
 	client = i_new(struct client, 1);
 	client->input = i_stream_create_file(hin, default_pool,
-					     MAX_INBUF_SIZE, FALSE);
+					     imap_max_line_length, FALSE);
 	client->output = o_stream_create_file(hout, default_pool, 4096, FALSE);
 
 	/* set timeout for reading expected data (eg. APPEND). This is
@@ -63,8 +60,7 @@
 
 	client->io = io_add(hin, IO_READ, _client_input, client);
 	client->parser = imap_parser_create(client->input, client->output,
-					    MAX_INBUF_SIZE,
-					    MAX_IMAP_ARG_ELEMENTS);
+					    imap_max_line_length);
         client->last_input = ioloop_time;
 
 	client->mailbox_flags.pool =

Index: cmd-append.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmd-append.c	15 Jun 2003 03:42:28 -0000	1.26
+++ cmd-append.c	2 Jul 2003 00:57:24 -0000	1.27
@@ -95,7 +95,7 @@
 	count = 0;
 	failed = TRUE;
 	save_parser = imap_parser_create(client->input, client->output,
-					 0, MAX_IMAP_ARG_ELEMENTS);
+					 imap_max_line_length);
 
 	for (;;) {
 		/* [<flags>] [<internal date>] <message literal> */

Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap/common.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- common.h	30 Jun 2003 15:54:17 -0000	1.7
+++ common.h	2 Jul 2003 00:57:24 -0000	1.8
@@ -4,17 +4,19 @@
 #include "lib.h"
 #include "client.h"
 
-/* max. number of IMAP argument elements to accept. The maximum memory usage
-   for command from user is around MAX_INBUF_SIZE * MAX_IMAP_ARG_ELEMENTS */
-#define MAX_IMAP_ARG_ELEMENTS 128
-
 /* Disconnect client after idling this many seconds */
 #define CLIENT_IDLE_TIMEOUT (60*30)
 
+/* RFC-2683 recommends at least 8000 bytes. Some clients however don't
+   break large message sets to multiple commands, so we're pretty liberal
+   by default. */
+#define DEFAULT_IMAP_MAX_LINE_LENGTH 65536
+
 #define DEFAULT_MAX_CUSTOM_FLAG_LENGTH 50
 
 extern struct ioloop *ioloop;
 extern unsigned int max_custom_flag_length, mailbox_check_interval;
+extern unsigned int imap_max_line_length;
 
 extern string_t *capability_string;
 

Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/main.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- main.c	30 Jun 2003 15:54:17 -0000	1.35
+++ main.c	2 Jul 2003 00:57:24 -0000	1.36
@@ -22,6 +22,7 @@
 
 struct ioloop *ioloop;
 unsigned int max_custom_flag_length, mailbox_check_interval;
+unsigned int imap_max_line_length;
 
 static struct module *modules;
 static char log_prefix[128]; /* syslog() needs this to be permanent */
@@ -126,6 +127,11 @@
 				"autodetection failed (home %s)", home);
 		}
 	}
+
+	str = getenv("IMAP_MAX_LINE_LENGTH");
+	imap_max_line_length = str != NULL ?
+		(unsigned int)strtoul(str, NULL, 10) :
+		DEFAULT_IMAP_MAX_LINE_LENGTH;
 
 	str = getenv("MAIL_MAX_FLAG_LENGTH");
 	max_custom_flag_length = str != NULL ?



More information about the dovecot-cvs mailing list