diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2022-01-17 21:26:40 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2022-01-17 21:26:40 +0000 |
commit | c52ec5f8f772abd9b47b256159b6398e59d759ec (patch) | |
tree | 3e0473d36d5d936a21d27ea13ae122f7ad8991b4 /src/libmime | |
parent | e27291f671d8707f2f98d62448b0fdf4f205fcd0 (diff) | |
download | rspamd-c52ec5f8f772abd9b47b256159b6398e59d759ec.tar.gz rspamd-c52ec5f8f772abd9b47b256159b6398e59d759ec.zip |
[Minor] Place obfuscated check properly to count u16 characters and not u8
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/archives.c | 30 |
1 files 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; |