From: Vsevolod Stakhov Date: Fri, 11 Jan 2019 15:24:47 +0000 (+0000) Subject: [Fix] Archive: Final fixes for 7z archives X-Git-Tag: 1.9.0~338 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3d4d0144a5bac2ece3d3b7e0c25519b0b3ea9798;p=rspamd.git [Fix] Archive: Final fixes for 7z archives Issue: #2629 Closes: #2629 --- diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 34c529a64..56e880577 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -809,7 +809,7 @@ rspamd_archive_7zip_read_vint (const guchar *start, gsize remain, guint64 *res) p += sizeof (guint64); \ } while (0) #define SZ_SKIP_BYTES(n) do { \ - if (end - p > (n)) { \ + if (end - p >= (n)) { \ p += (n); \ } \ else { \ @@ -1463,10 +1463,7 @@ rspamd_7zip_read_files_info (struct rspamd_task *task, case kATime: case kMTime: /* We don't care of these guys, but we still have to parse them, gah */ - if (sz == 0) { - goto end; - } - else { + if (sz > 0) { SZ_SKIP_BYTES (sz); } break; @@ -1507,9 +1504,10 @@ rspamd_7zip_read_files_info (struct rspamd_task *task, res = rspamd_7zip_ucs2_to_utf8 (task, p, fend); if (res != NULL) { - fentry = g_malloc0 (sizeof (fentry)); + fentry = g_malloc0 (sizeof (*fentry)); fentry->fname = res; g_ptr_array_add (arch->files, fentry); + msg_debug_archive ("7zip: found file %v", res); } else { msg_debug_archive ("bad 7zip name; %s", G_STRLOC); @@ -1521,10 +1519,7 @@ rspamd_7zip_read_files_info (struct rspamd_task *task, break; case kDummy: case kWinAttributes: - if (sz == 0) { - goto end; - } - else { + if (sz > 0) { SZ_SKIP_BYTES (sz); } break;