]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Check for magic when checking for an archive
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 27 Sep 2017 19:44:56 +0000 (20:44 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 17 Oct 2017 22:26:15 +0000 (00:26 +0200)
Issue: #1848
Closes: #1848
MFH: 1.6

src/libmime/archives.c

index 2123e1131e6c63abf37c96d0f352f73adab57480..7d4f1c1c6b57b2ee3474f92c7e48561a460a6418 100644 (file)
@@ -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;
                                }
                        }