commit e7059c9: [Fix] Fix utf8 validation for symbols options and empty strings
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Nov 18 12:21:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-11-18 12:14:54 +0000
URL: https://github.com/rspamd/rspamd/commit/e7059c97ee940941455a1d0b8fe0adb292ce8d7c
[Fix] Fix utf8 validation for symbols options and empty strings
---
src/libmime/scan_result.c | 2 +-
src/libutil/str_util.c | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/libmime/scan_result.c b/src/libmime/scan_result.c
index 7b1acd3e9..23964c88e 100644
--- a/src/libmime/scan_result.c
+++ b/src/libmime/scan_result.c
@@ -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;
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index 9f4ad1cb0..8fcaca484 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -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;
More information about the Commits
mailing list