diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-15 17:54:02 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-01-15 17:54:02 +0000 |
commit | 8082d02b0291ac6bf630eb99a307e13e7cb03ae4 (patch) | |
tree | b0e6c3418f86927a9cb7e6be9be734d9a375ed4d /src/libmime/archives.c | |
parent | 6296a24a75b00bd04d16031d6b09080baa7c56c1 (diff) | |
download | rspamd-8082d02b0291ac6bf630eb99a307e13e7cb03ae4.tar.gz rspamd-8082d02b0291ac6bf630eb99a307e13e7cb03ae4.zip |
[Minor] Archives: Fix gzip file detection error
Diffstat (limited to 'src/libmime/archives.c')
-rw-r--r-- | src/libmime/archives.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 56e880577..f546570a9 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -1757,9 +1757,19 @@ rspamd_archive_process_gzip (struct rspamd_task *task, const gchar *fname_start = part->cd->filename.begin; f = g_malloc0 (sizeof (*f)); - f->fname = g_string_sized_new (dot_pos - slash_pos); - g_string_append_len (f->fname, fname_start, - dot_pos - fname_start); + + if (memchr (fname_start, '.', part->cd->filename.len) != dot_pos) { + /* Double dots, something like foo.exe.gz */ + f->fname = g_string_sized_new (dot_pos - fname_start); + g_string_append_len (f->fname, fname_start, + dot_pos - fname_start); + } + else { + /* Single dot, something like foo.gzz */ + f->fname = g_string_sized_new (part->cd->filename.len); + g_string_append_len (f->fname, fname_start, + part->cd->filename.len); + } msg_debug_archive ("fallback to gzip filename based on cd: %v", f->fname); |