]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix adding of the empty archive file for gzip
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 13 Jul 2020 14:40:43 +0000 (15:40 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 13 Jul 2020 14:40:43 +0000 (15:40 +0100)
src/libmime/archives.c

index 32a251c945e91027c2c5980431fc8a8881058a3a..12fa15276b7dd4d5520cfbe8c36e9bce93844474 100644 (file)
@@ -68,11 +68,11 @@ rspamd_archive_file_try_utf (struct rspamd_task *task,
                UConverter *utf8_converter;
 
                conv = rspamd_mime_get_converter_cached (charset, task->task_pool,
-                               FALSE, &uc_err);
+                               TRUE, &uc_err);
                utf8_converter = rspamd_get_utf8_converter ();
 
                if (conv == NULL) {
-                       msg_err_task ("cannot open converter for %s: %s",
+                       msg_info_task ("cannot open converter for %s: %s",
                                        charset, u_errorName (uc_err));
 
                        return NULL;
@@ -82,7 +82,7 @@ rspamd_archive_file_try_utf (struct rspamd_task *task,
                r = rspamd_converter_to_uchars (conv, tmp, inlen + 1,
                                in, inlen, &uc_err);
                if (!U_SUCCESS (uc_err)) {
-                       msg_err_task ("cannot convert data to unicode from %s: %s",
+                       msg_info_task ("cannot convert data to unicode from %s: %s",
                                        charset, u_errorName (uc_err));
                        g_free (tmp);
 
@@ -95,7 +95,7 @@ rspamd_archive_file_try_utf (struct rspamd_task *task,
                r = ucnv_fromUChars (utf8_converter, res->str, dlen, tmp, r, &uc_err);
 
                if (!U_SUCCESS (uc_err)) {
-                       msg_err_task ("cannot convert data from unicode from %s: %s",
+                       msg_info_task ("cannot convert data from unicode from %s: %s",
                                        charset, u_errorName (uc_err));
                        g_free (tmp);
                        g_string_free (res, TRUE);
@@ -1750,7 +1750,13 @@ rspamd_archive_process_gzip (struct rspamd_task *task,
                                        f->fname = rspamd_archive_file_try_utf (task, fname_start,
                                                        p - fname_start);
 
-                                       g_ptr_array_add (arch->files, f);
+                                       if (f->fname) {
+                                               g_ptr_array_add (arch->files, f);
+                                       }
+                                       else {
+                                               /* Invalid filename, skip */
+                                               g_free (f);
+                                       }
 
                                        goto set;
                                }