From cdffb78f605ead15aedf403a13862215cb013923 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 9 Feb 2017 12:05:51 +0000 Subject: [Fix] Fix processing of emails with name only --- src/libmime/email_addr.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/libmime/email_addr.c') diff --git a/src/libmime/email_addr.c b/src/libmime/email_addr.c index b1d54e73b..368b31d34 100644 --- a/src/libmime/email_addr.c +++ b/src/libmime/email_addr.c @@ -125,7 +125,18 @@ rspamd_email_address_add (rspamd_mempool_t *pool, guint nlen; elt = g_slice_alloc (sizeof (*elt)); - memcpy (elt, addr, sizeof (*addr)); + + if (addr != NULL) { + memcpy (elt, addr, sizeof (*addr)); + } + else { + elt->addr = ""; + elt->domain = ""; + elt->raw = "<>"; + elt->raw_len = 2; + elt->user = ""; + elt->flags |= RSPAMD_EMAIL_ADDR_EMPTY; + } if ((elt->flags & RSPAMD_EMAIL_ADDR_QUOTED) && elt->addr[0] == '"') { if (elt->flags & RSPAMD_EMAIL_ADDR_HAS_BACKSLASH) { @@ -323,6 +334,16 @@ rspamd_email_address_from_mime (rspamd_mempool_t *pool, /* Handle leftover */ switch (state) { case parse_name: + /* Assume the whole header as name (bad thing) */ + if (p > c) { + while (p > c && g_ascii_isspace (*p)) { + p --; + } + + g_string_append_len (ns, c, p - c + 1); + rspamd_email_address_add (pool, res, NULL, ns); + } + break; case parse_addr: if (p > c) { rspamd_smtp_addr_parse (c, p - c, &addr); -- cgit v1.2.3