From: Vsevolod Stakhov Date: Wed, 27 Sep 2017 19:44:56 +0000 (+0100) Subject: [Fix] Check for magic when checking for an archive X-Git-Tag: 1.6.5~3^2~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=add7587e2ac6826ef7714c006192be94bcde657c;p=rspamd.git [Fix] Check for magic when checking for an archive Issue: #1848 Closes: #1848 MFH: 1.6 --- 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; } }