122 lines
3.9 KiB
Diff
122 lines
3.9 KiB
Diff
diff -up dovecot-2.3.8/src/lib-smtp/smtp-address.c.smtppre dovecot-2.3.8/src/lib-smtp/smtp-address.c
|
|
--- dovecot-2.3.8/src/lib-smtp/smtp-address.c.smtppre 2019-10-08 10:46:18.000000000 +0200
|
|
+++ dovecot-2.3.8/src/lib-smtp/smtp-address.c 2020-05-29 19:11:19.340621409 +0200
|
|
@@ -467,7 +467,7 @@ void smtp_address_detail_parse(pool_t po
|
|
*detail_r = p+1;
|
|
}
|
|
|
|
- if (address->domain == NULL)
|
|
+ if (address->domain == NULL || *address->domain == '\0')
|
|
*username_r = user;
|
|
else if (strchr(user, '@') == NULL ) {
|
|
/* username is just glued to the domain... no SMTP escaping */
|
|
@@ -548,7 +548,7 @@ void smtp_address_write(string_t *out,
|
|
if (quoted)
|
|
str_append_c(out, '\"');
|
|
|
|
- if (address->domain == NULL)
|
|
+ if (address->domain == NULL || *address->domain == '\0')
|
|
return;
|
|
|
|
str_append_c(out, '@');
|
|
@@ -587,8 +587,12 @@ void smtp_address_init(struct smtp_addre
|
|
const char *localpart, const char *domain)
|
|
{
|
|
i_zero(address);
|
|
+ if (localpart == NULL || *localpart == '\0')
|
|
+ return;
|
|
+
|
|
address->localpart = localpart;
|
|
- address->domain = (localpart == NULL ? NULL : domain);
|
|
+ if (domain != NULL && *domain != '\0')
|
|
+ address->domain = domain;
|
|
}
|
|
|
|
int smtp_address_init_from_msg(struct smtp_address *address,
|
|
@@ -597,7 +601,7 @@ int smtp_address_init_from_msg(struct sm
|
|
const char *p;
|
|
|
|
i_zero(address);
|
|
- if (msg_addr->mailbox == NULL)
|
|
+ if (msg_addr->mailbox == NULL || *msg_addr->mailbox == '\0')
|
|
return 0;
|
|
|
|
/* The message_address_parse() function allows UTF-8 codepoints in
|
|
@@ -609,7 +613,8 @@ int smtp_address_init_from_msg(struct sm
|
|
}
|
|
|
|
address->localpart = msg_addr->mailbox;
|
|
- address->domain = msg_addr->domain;
|
|
+ if (msg_addr->domain != NULL && *msg_addr->domain != '\0')
|
|
+ address->domain = msg_addr->domain;
|
|
return 0;
|
|
}
|
|
|
|
@@ -617,8 +622,8 @@ struct smtp_address *
|
|
smtp_address_clone(pool_t pool, const struct smtp_address *src)
|
|
{
|
|
struct smtp_address *new;
|
|
- size_t size, lpsize, dsize = 0;
|
|
- char *data, *localpart, *domain = NULL;
|
|
+ size_t size, lpsize = 0, dsize = 0;
|
|
+ char *data, *localpart = NULL, *domain = NULL;
|
|
|
|
if (smtp_address_isnull(src))
|
|
return NULL;
|
|
@@ -626,17 +631,21 @@ smtp_address_clone(pool_t pool, const st
|
|
/* @UNSAFE */
|
|
|
|
size = sizeof(struct smtp_address);
|
|
- lpsize = strlen(src->localpart) + 1;
|
|
- size = MALLOC_ADD(size, lpsize);
|
|
- if (src->domain != NULL) {
|
|
+ if (src->localpart != NULL && *src->localpart != '\0') {
|
|
+ lpsize = strlen(src->localpart) + 1;
|
|
+ size = MALLOC_ADD(size, lpsize);
|
|
+ }
|
|
+ if (src->domain != NULL && *src->domain != '\0') {
|
|
dsize = strlen(src->domain) + 1;
|
|
size = MALLOC_ADD(size, dsize);
|
|
}
|
|
|
|
data = p_malloc(pool, size);
|
|
new = (struct smtp_address *)data;
|
|
- localpart = PTR_OFFSET(data, sizeof(*new));
|
|
- memcpy(localpart, src->localpart, lpsize);
|
|
+ if (lpsize > 0) {
|
|
+ localpart = PTR_OFFSET(data, sizeof(*new));
|
|
+ memcpy(localpart, src->localpart, lpsize);
|
|
+ }
|
|
if (dsize > 0) {
|
|
domain = PTR_OFFSET(data, sizeof(*new) + lpsize);
|
|
memcpy(domain, src->domain, dsize);
|
|
@@ -681,8 +690,8 @@ smtp_address_clone_temp(const struct smt
|
|
return NULL;
|
|
|
|
new = t_new(struct smtp_address, 1);
|
|
- new->localpart = t_strdup(src->localpart);
|
|
- new->domain = t_strdup(src->domain);
|
|
+ new->localpart = t_strdup_empty(src->localpart);
|
|
+ new->domain = t_strdup_empty(src->domain);
|
|
return new;
|
|
}
|
|
|
|
@@ -720,7 +729,7 @@ smtp_address_add_detail(pool_t pool, con
|
|
new_addr = p_new(pool, struct smtp_address, 1);
|
|
new_addr->localpart = p_strconcat(pool,
|
|
address->localpart, delim, detail, NULL);
|
|
- new_addr->domain = p_strdup(pool, address->domain);
|
|
+ new_addr->domain = p_strdup_empty(pool, address->domain);
|
|
|
|
return new_addr;
|
|
}
|
|
@@ -737,7 +746,7 @@ smtp_address_add_detail_temp(const struc
|
|
new_addr = t_new(struct smtp_address, 1);
|
|
new_addr->localpart = t_strconcat(
|
|
address->localpart, delim, detail, NULL);
|
|
- new_addr->domain = t_strdup(address->domain);
|
|
+ new_addr->domain = t_strdup_empty(address->domain);
|
|
|
|
return new_addr;
|
|
}
|