aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_headers.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-08 13:38:50 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-02-08 13:46:57 +0000
commit225a25c91fc00e6d2523a7352c266104cd2d220a (patch)
tree489c04475aaeda0361a85fd13dd1301585e5377c /src/libmime/mime_headers.c
parent60a221d3e43e1bf2d03b8fd1faec9b3ad78672dc (diff)
downloadrspamd-225a25c91fc00e6d2523a7352c266104cd2d220a.tar.gz
rspamd-225a25c91fc00e6d2523a7352c266104cd2d220a.zip
[Fix] Filter bad characters from message id
Issue: #1403
Diffstat (limited to 'src/libmime/mime_headers.c')
-rw-r--r--src/libmime/mime_headers.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 282579548..35c13d1f3 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -28,6 +28,8 @@ rspamd_mime_header_check_special (struct rspamd_task *task,
{
guint64 h;
struct received_header *recv;
+ const gchar *p, *end;
+ gchar *id;
h = rspamd_icase_hash (rh->name, strlen (rh->name), 0xdeadbabe);
@@ -56,7 +58,6 @@ rspamd_mime_header_check_special (struct rspamd_task *task,
rh->value, strlen (rh->value), task->from_mime);
break;
case 0x43A558FC7C240226ULL: /* message-id */ {
- gchar *p, *end;
p = rh->decoded;
end = p + strlen (p);
@@ -64,14 +65,32 @@ rspamd_mime_header_check_special (struct rspamd_task *task,
if (*p == '<') {
p ++;
- if (end > p && *(end - 1) == '>') {
- *(end - 1) = '\0';
- p = rspamd_mempool_strdup (task->task_pool, p);
- *(end - 1) = '>';
+ if (end > p) {
+ gchar *d;
+
+ if (*(end - 1) == '>') {
+ end --;
+ }
+
+ id = rspamd_mempool_alloc (task->task_pool, end - p + 1);
+ d = id;
+
+ while (p < end) {
+ if (g_ascii_isgraph (*p)) {
+ *d++ = *p++;
+ }
+ else {
+ *d++ = '?';
+ p++;
+ }
+ }
+
+ *d = '\0';
+
+ task->message_id = id;
}
}
- task->message_id = p;
break;
}
case 0xB91D3910358E8212ULL: /* subject */