]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix utf8 validation for symbols options and empty strings
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 18 Nov 2019 12:14:54 +0000 (12:14 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 18 Nov 2019 12:14:54 +0000 (12:14 +0000)
src/libmime/scan_result.c
src/libutil/str_util.c

index 7b1acd3e91e449ab65b82fac1b5eb52b22546c77..23964c88e17e71c30ce69771075a884cb9b9b403 100644 (file)
@@ -529,7 +529,7 @@ rspamd_task_add_result_option (struct rspamd_task *task,
 
                vlen = strlen (val);
 
-               if (!rspamd_fast_utf8_validate (val, vlen)) {
+               if (rspamd_fast_utf8_validate (val, vlen) == 0) {
                        opt_cpy = rspamd_str_make_utf_valid (val, vlen, &vlen,
                                        task->task_pool);
                        val = opt_cpy;
index 9f4ad1cb0cebecf18aa0dae177c3dc15f84ea3e7..8fcaca484618214599d0f81eeae4c55dac14b09f 100644 (file)
@@ -3067,7 +3067,11 @@ rspamd_str_make_utf_valid (const guchar *src, gsize slen,
        }
 
        if (slen == 0) {
-               return NULL;
+               if (dstlen) {
+                       *dstlen = 0;
+               }
+
+               return pool ? rspamd_mempool_strdup (pool, "") : g_strdup ("");
        }
 
        p = src;