aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-09-10 14:07:44 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-09-10 14:07:44 +0100
commit0438950996eab6a879b7b6eafdd374f9f2cc9614 (patch)
treeda50181e8a1b2c3f780ba0de37c31f9eb49bb5bc /src/libutil
parent719752929adf89a5ddbaf4542475cde1af9ab676 (diff)
downloadrspamd-0438950996eab6a879b7b6eafdd374f9f2cc9614.tar.gz
rspamd-0438950996eab6a879b7b6eafdd374f9f2cc9614.zip
Fix serious issue with non-ascii characters in fuzzy.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/fuzzy.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libutil/fuzzy.c b/src/libutil/fuzzy.c
index 3ba20bbad..29a6a898c 100644
--- a/src/libutil/fuzzy.c
+++ b/src/libutil/fuzzy.c
@@ -320,7 +320,7 @@ fuzzy_init_part (struct mime_text_part *part,
gsize max_diff)
{
fuzzy_hash_t *new, *new2;
- gchar *c, *end, *begin;
+ gchar *c, *end, *begin, *p;
gsize real_len = 0, len = part->content->len;
GList *cur_offset;
struct process_exception *cur_ex = NULL;
@@ -351,9 +351,13 @@ fuzzy_init_part (struct mime_text_part *part,
else {
uc = g_utf8_get_char (c);
if (g_unichar_isalnum (uc)) {
- real_len++;
+ p = g_utf8_next_char (c);
+ real_len += p - c;
}
- c = g_utf8_next_char (c);
+ else {
+ p = g_utf8_next_char (c);
+ }
+ c = p;
}
}
}
@@ -378,7 +382,7 @@ fuzzy_init_part (struct mime_text_part *part,
write_diff = real_len > 0 && real_len < max_diff;
if (write_diff) {
- part->diff_str = fstralloc (pool, real_len);
+ part->diff_str = fstralloc (pool, real_len + 1);
}
else {
part->diff_str = NULL;