Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3201:2bf86099376e HEAD
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.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 14 Mar 2005 21:08:59 +0200 |
parents | a9a5a399a027 |
children | 2661cfd533c0 |
files | src/lib-mail/message-address.c |
diffstat | 1 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/message-address.c Mon Mar 14 16:32:48 2005 +0200 +++ b/src/lib-mail/message-address.c Mon Mar 14 21:08:59 2005 +0200 @@ -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@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@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, '>'); }