commit 8082d02: [Minor] Archives: Fix gzip file detection error

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jan 15 17:56:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-01-15 17:54:02 +0000
URL: https://github.com/rspamd/rspamd/commit/8082d02b0291ac6bf630eb99a307e13e7cb03ae4 (HEAD -> master)

[Minor] Archives: Fix gzip file detection error

---
 src/libmime/archives.c | 16 +++++++++++++---
 1 file 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);


More information about the Commits mailing list