aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-04 17:22:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-04 17:22:41 +0100
commitfe0b7b5c838bf966fabbb102d9fb8da93acdcaeb (patch)
treeb345bdb7386c3f0c9637043cff333f3bb3d42f98 /src
parentf2fe164e37c17dfc7228ac2ff69719d1407bf496 (diff)
downloadrspamd-fe0b7b5c838bf966fabbb102d9fb8da93acdcaeb.tar.gz
rspamd-fe0b7b5c838bf966fabbb102d9fb8da93acdcaeb.zip
[Feature] Add better zip files search algorithm
Diffstat (limited to 'src')
-rw-r--r--src/libmime/archives.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/libmime/archives.c b/src/libmime/archives.c
index 9a9d1da3a..99b004afa 100644
--- a/src/libmime/archives.c
+++ b/src/libmime/archives.c
@@ -145,6 +145,37 @@ rspamd_archive_process_zip (struct rspamd_task *task,
arch->size = part->content->len;
}
+static gboolean
+rspamd_archive_cheat_detect (struct rspamd_mime_part *part, const gchar *str)
+{
+ GMimeContentType *ct;
+ const gchar *fname, *p;
+
+ ct = part->type;
+
+ if (ct && ct->type && ct->subtype && strcmp (ct->type,
+ "application") == 0) {
+ if (rspamd_substring_search_caseless (ct->subtype, strlen (ct->subtype),
+ str, strlen (str)) != -1) {
+ return TRUE;
+ }
+ }
+
+ fname = part->filename;
+
+ if (fname && strlen (fname) > strlen (str)) {
+ p = fname + strlen (fname) - strlen (str);
+
+ if (rspamd_lc_cmp (p, str, strlen (str)) == 0) {
+ if (*(p - 1) == '.') {
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
void
rspamd_archives_process (struct rspamd_task *task)
{
@@ -153,9 +184,11 @@ rspamd_archives_process (struct rspamd_task *task)
for (i = 0; i < task->parts->len; i ++) {
part = g_ptr_array_index (task->parts, i);
- if (g_mime_content_type_is_type (part->type, "application", "zip") &&
- part->content->len > 0) {
- rspamd_archive_process_zip (task, part);
+
+ if (part->content->len > 0) {
+ if (rspamd_archive_cheat_detect (part, "zip")) {
+ rspamd_archive_process_zip (task, part);
+ }
}
}
}