From add7587e2ac6826ef7714c006192be94bcde657c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 27 Sep 2017 20:44:56 +0100 Subject: [PATCH] [Fix] Check for magic when checking for an archive Issue: #1848 Closes: #1848 MFH: 1.6 --- src/libmime/archives.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 2123e1131..7d4f1c1c6 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -573,7 +573,19 @@ rspamd_archive_cheat_detect (struct rspamd_mime_part *part, const gchar *str, &srch) == 0) { if (rspamd_substring_search_caseless (ct->subtype.begin, ct->subtype.len, str, strlen (str)) != -1) { - return TRUE; + /* We still need to check magic, see #1848 */ + if (magic_start != NULL) { + if (part->parsed_data.len > magic_len && + memcmp (part->parsed_data.begin, + magic_start, magic_len) == 0) { + return TRUE; + } + /* No magic, refuse this type of archive */ + return FALSE; + } + else { + return TRUE; + } } } @@ -585,6 +597,16 @@ rspamd_archive_cheat_detect (struct rspamd_mime_part *part, const gchar *str, if (rspamd_lc_cmp (p, str, strlen (str)) == 0) { if (*(p - 1) == '.') { + if (magic_start != NULL) { + if (part->parsed_data.len > magic_len && + memcmp (part->parsed_data.begin, + magic_start, magic_len) == 0) { + return TRUE; + } + /* No magic, refuse this type of archive */ + return FALSE; + } + return TRUE; } } -- 2.39.5