[dovecot-cvs] dovecot/src/lib-imap imap-envelope.c,1.15,1.16 imap-match.c,1.2,1.3 imap-match.h,1.2,1.3 imap-message-cache.c,1.25,1.26 imap-parser.c,1.24,1.25 imap-util.c,1.3,1.4

cras at procontrol.fi cras at procontrol.fi
Wed Dec 18 17:15:43 EET 2002


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

Modified Files:
	imap-envelope.c imap-match.c imap-match.h imap-message-cache.c 
	imap-parser.c imap-util.c 
Log Message:
Marked all non-trivial buffer modifications with @UNSAFE tag. Several
cleanups and a couple of minor bugfixes.



Index: imap-envelope.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-envelope.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- imap-envelope.c	17 Dec 2002 04:28:41 -0000	1.15
+++ imap-envelope.c	18 Dec 2002 15:15:41 -0000	1.16
@@ -21,12 +21,7 @@
 static Rfc822Address *parse_address(Pool pool, const char *value,
 				    size_t value_len)
 {
-	Rfc822Address *ret;
-
-	t_push();
-	ret = rfc822_address_parse(pool, t_strndup(value, value_len));
-	t_pop();
-	return ret;
+	return rfc822_address_parse(pool, t_strndup(value, value_len));
 }
 
 void imap_envelope_parse_header(Pool pool, MessagePartEnvelopeData **data,
@@ -38,6 +33,8 @@
 		(*data)->pool = pool;
 	}
 
+	t_push();
+
 	if (strcasecmp(name, "Date") == 0 && (*data)->date == NULL)
 		(*data)->date = imap_quote_value(pool, value, value_len);
 	else if (strcasecmp(name, "Subject") == 0 && (*data)->subject == NULL)
@@ -60,6 +57,8 @@
 	else if (strcasecmp(name, "Message-Id") == 0 &&
 		 (*data)->message_id == NULL)
 		(*data)->message_id = imap_quote_value(pool, value, value_len);
+
+	t_pop();
 }
 
 static void imap_write_address(TempString *str, Rfc822Address *addr)

Index: imap-match.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-match.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- imap-match.c	3 Dec 2002 22:44:39 -0000	1.2
+++ imap-match.c	18 Dec 2002 15:15:41 -0000	1.3
@@ -21,33 +21,34 @@
 static const char inbox[] = "INBOX";
 #define INBOXLEN (sizeof(inbox) - 1)
 
-ImapMatchGlob *imap_match_init(const char *str, int inboxcase, char separator)
+ImapMatchGlob *imap_match_init(const char *mask, int inboxcase, char separator)
 {
 	ImapMatchGlob *glob;
 	const char *p, *inboxp;
 	char *dst;
 
 	/* +1 from struct */
-	glob = t_malloc(sizeof(ImapMatchGlob) + strlen(str));
+	glob = t_malloc(sizeof(ImapMatchGlob) + strlen(mask));
 	glob->sep_char = separator;
 
+	/* @UNSAFE: compress the mask */
 	dst = glob->mask;
-	while (*str != '\0') {
-		if (*str == '*' || *str == '%') {
+	while (*mask != '\0') {
+		if (*mask == '*' || *mask == '%') {
 			/* remove duplicate hierarchy wildcards */
-			while (*str == '%') str++;
+			while (*mask == '%') mask++;
 
 			/* "%*" -> "*" */
-			if (*str == '*') {
+			if (*mask == '*') {
 				/* remove duplicate wildcards */
-				while (*str == '*' || *str == '%')
-					str++;
+				while (*mask == '*' || *mask == '%')
+					mask++;
 				*dst++ = '*';
 			} else {
 				*dst++ = '%';
 			}
 		} else {
-			*dst++ = *str++;
+			*dst++ = *mask++;
 		}
 	}
 	*dst++ = '\0';

Index: imap-match.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-match.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- imap-match.h	3 Dec 2002 22:44:39 -0000	1.2
+++ imap-match.h	18 Dec 2002 15:15:41 -0000	1.3
@@ -5,7 +5,7 @@
 
 /* If inboxcase is TRUE, the "INBOX" string at the beginning of line is
    compared case-insensitively */
-ImapMatchGlob *imap_match_init(const char *str, int inboxcase, char separator);
+ImapMatchGlob *imap_match_init(const char *mask, int inboxcase, char separator);
 
 /* Returns 1 if matched, 0 if it didn't match, but could match with additional
    hierarchies, -1 if definitely didn't match */

Index: imap-message-cache.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-message-cache.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- imap-message-cache.c	6 Dec 2002 01:09:22 -0000	1.25
+++ imap-message-cache.c	18 Dec 2002 15:15:41 -0000	1.26
@@ -228,7 +228,8 @@
 			   do it only if the file isn't open already, since
 			   this takes more CPU than parsing message headers. */
 			value = cache->iface->get_cached_field(
-				IMAP_CACHE_BODYSTRUCTURE, cache->context);
+						IMAP_CACHE_BODYSTRUCTURE,
+						cache->context);
 			if (value != NULL) {
 				value = imap_body_parse_from_bodystructure(
 									value);

Index: imap-parser.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-parser.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- imap-parser.c	9 Dec 2002 15:25:20 -0000	1.24
+++ imap-parser.c	18 Dec 2002 15:15:41 -0000	1.25
@@ -136,6 +136,7 @@
 
 	i_assert(parser->cur_list != NULL);
 
+	/* @UNSAFE */
 	if (parser->cur_list->size == parser->cur_list->alloc)
 		imap_args_realloc(parser, parser->cur_list->alloc * 2);
 

Index: imap-util.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-imap/imap-util.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- imap-util.c	19 Oct 2002 14:51:59 -0000	1.3
+++ imap-util.c	18 Dec 2002 15:15:41 -0000	1.4
@@ -63,7 +63,7 @@
 	if (esc == 0)
 		return str;
 
-	/* escape them */
+	/* @UNSAFE: escape them */
 	p = ret = t_malloc(i + esc + 1);
 	for (; *str != '\0'; str++) {
 		if (IS_ESCAPED_CHAR(str[i]))




More information about the dovecot-cvs mailing list