[dovecot-cvs] dovecot/src/lib-mail message-address.c,1.10,1.11

cras at dovecot.org cras at dovecot.org
Mon Mar 14 21:09:02 EET 2005


Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv17652

Modified Files:
	message-address.c 
Log Message:
If mailbox name was missing from message address, we didn't set it to
MISSING_MAILBOX as we should have, which caused crashing if the field was
tried to be SEARCHed. Also cleaned up the code a bit.



Index: message-address.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-address.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- message-address.c	6 Jan 2005 20:50:36 -0000	1.10
+++ message-address.c	14 Mar 2005 19:08:59 -0000	1.11
@@ -182,7 +182,7 @@
 	}
 
 	if (ctx->addr.mailbox == NULL)
-		ctx->addr.domain = p_strdup(ctx->pool, "MISSING_MAILBOX");
+		ctx->addr.mailbox = p_strdup(ctx->pool, "MISSING_MAILBOX");
 	if (ctx->addr.domain == NULL)
 		ctx->addr.domain = p_strdup(ctx->pool, "MISSING_DOMAIN");
 	add_address(ctx);
@@ -299,11 +299,14 @@
 
 		if (addr->domain == NULL) {
 			if (!in_group) {
+				/* beginning of group. mailbox is the group
+				   name, others are NULL. */
 				if (addr->mailbox != NULL)
 					str_append(str, addr->mailbox);
 				str_append(str, ": ");
 				first = TRUE;
 			} else {
+				/* end of group. all fields should be NULL. */
 				i_assert(addr->mailbox == NULL);
 
 				/* cut out the ", " */
@@ -314,14 +317,14 @@
 			in_group = !in_group;
 		} else if ((addr->name == NULL || *addr->name == '\0') &&
 			   addr->route == NULL) {
+			/* no name and no route. use only mailbox at domain */
 			i_assert(addr->mailbox != NULL);
 
 			str_append(str, addr->mailbox);
-			if (addr->domain != NULL) {
-				str_append_c(str, '@');
-				str_append(str, addr->domain);
-			}
+			str_append_c(str, '@');
+			str_append(str, addr->domain);
 		} else {
+			/* name and/or route. use full <mailbox at domain> Name */
 			i_assert(addr->mailbox != NULL);
 
 			if (addr->name != NULL) {
@@ -335,10 +338,8 @@
 				str_append_c(str, ':');
 			}
 			str_append(str, addr->mailbox);
-			if (addr->domain != NULL) {
-				str_append_c(str, '@');
-				str_append(str, addr->domain);
-			}
+			str_append_c(str, '@');
+			str_append(str, addr->domain);
 			str_append_c(str, '>');
 		}
 



More information about the dovecot-cvs mailing list