diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-09 12:05:51 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-09 12:30:28 +0000 |
commit | cdffb78f605ead15aedf403a13862215cb013923 (patch) | |
tree | 213e1524d66279b751ab9a3514cf2aeecd3c2183 /src/libmime/email_addr.c | |
parent | 326e04c91f4852810f6b3eb02c34e1907e7ccb15 (diff) | |
download | rspamd-cdffb78f605ead15aedf403a13862215cb013923.tar.gz rspamd-cdffb78f605ead15aedf403a13862215cb013923.zip |
[Fix] Fix processing of emails with name only
Diffstat (limited to 'src/libmime/email_addr.c')
-rw-r--r-- | src/libmime/email_addr.c | 23 |
1 files changed, 22 insertions, 1 deletions
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); |