From: Vsevolod Stakhov Date: Mon, 17 Jan 2022 21:26:40 +0000 (+0000) Subject: [Minor] Place obfuscated check properly to count u16 characters and not u8 X-Git-Tag: 3.2~93 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c52ec5f8f772abd9b47b256159b6398e59d759ec;p=thirdparty%2Frspamd.git [Minor] Place obfuscated check properly to count u16 characters and not u8 --- diff --git a/src/libmime/archives.c b/src/libmime/archives.c index 12a35ae5cc..3b0e898420 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;