[dovecot-cvs] dovecot/src/lib-imap imap-parser.c,1.35,1.36 imap-parser.h,1.11,1.12

cras at procontrol.fi cras at procontrol.fi
Thu Jan 23 05:28:48 EET 2003


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

Modified Files:
	imap-parser.c imap-parser.h 
Log Message:
Disconnect client if given non-sync literal size is too large. Better than
eating the input.



Index: imap-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-parser.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- imap-parser.c	23 Jan 2003 03:17:10 -0000	1.35
+++ imap-parser.c	23 Jan 2003 03:28:46 -0000	1.36
@@ -45,6 +45,7 @@
 	unsigned int literal_nonsync:1;
 	unsigned int inside_bracket:1;
 	unsigned int eol:1;
+	unsigned int fatal_error:1;
 };
 
 /* @UNSAFE */
@@ -113,8 +114,9 @@
 	imap_args_realloc(parser, LIST_ALLOC_SIZE);
 }
 
-const char *imap_parser_get_error(struct imap_parser *parser)
+const char *imap_parser_get_error(struct imap_parser *parser, int *fatal)
 {
+        *fatal = parser->fatal_error;
 	return parser->error;
 }
 
@@ -334,6 +336,7 @@
 		if (parser->literal_size > parser->max_literal_size) {
 			/* too long string, abort. */
 			parser->error = "Literal size too large";
+			parser->fatal_error = TRUE;
 			return FALSE;
 		}
 

Index: imap-parser.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-parser.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- imap-parser.h	23 Jan 2003 03:17:10 -0000	1.11
+++ imap-parser.h	23 Jan 2003 03:28:46 -0000	1.12
@@ -68,8 +68,10 @@
 /* Reset the parser to initial state. */
 void imap_parser_reset(struct imap_parser *parser);
 
-/* Return the last error in parser. */
-const char *imap_parser_get_error(struct imap_parser *parser);
+/* Return the last error in parser. fatal is set to TRUE if there's no way to
+   continue parsing, currently only if too large non-sync literal size was
+   given. */
+const char *imap_parser_get_error(struct imap_parser *parser, int *fatal);
 
 /* Read a number of arguments. This function doesn't call i_stream_read(), you
    need to do that. Returns number of arguments read (may be less than count




More information about the dovecot-cvs mailing list