commit c52ec5f: [Minor] Place obfuscated check properly to count u16 characters and not u8

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jan 17 21:28:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-01-17 21:26:40 +0000
URL: https://github.com/rspamd/rspamd/commit/c52ec5f8f772abd9b47b256159b6398e59d759ec (HEAD -> master)

[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;
 


More information about the Commits mailing list