From c52ec5f8f772abd9b47b256159b6398e59d759ec Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 17 Jan 2022 21:26:40 +0000 Subject: [PATCH] [Minor] Place obfuscated check properly to count u16 characters and not u8 --- src/libmime/archives.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 12a35ae5c..3b0e89842 100644 --- a/src/libmime/archives.c +++ b/src/libmime/archives.c @@ -96,6 +96,21 @@ rspamd_archive_file_try_utf (struct rspamd_task *task, return NULL; } + int i = 0; + + while (i < r) { + UChar32 uc; + + U16_NEXT(tmp, i, r, uc); + + if (IS_ZERO_WIDTH_SPACE(uc) || u_iscntrl(uc)) { + msg_info_task("control character in archive file name found: 0x%02xd " + "(filename=%T)", uc, arch->archive_name); + fentry->flags |= RSPAMD_ARCHIVE_FILE_OBFUSCATED; + break; + } + } + clen = ucnv_getMaxCharSize (utf8_converter); dlen = UCNV_GET_MAX_BYTES_FOR_STRING (r, clen); res = g_string_sized_new (dlen); @@ -112,21 +127,6 @@ rspamd_archive_file_try_utf (struct rspamd_task *task, return NULL; } - int i = 0; - - while (i < r) { - UChar32 uc; - - U16_NEXT(tmp, i, r, uc); - - if (IS_ZERO_WIDTH_SPACE(uc) || u_iscntrl(uc)) { - msg_info_task("control character in archive file name found: 0x%02xd " - "(filename=%T)", uc, arch->archive_name); - fentry->flags |= RSPAMD_ARCHIVE_FILE_OBFUSCATED; - break; - } - } - g_free (tmp); res->len = r; -- 2.39.5