summaryrefslogtreecommitdiffstats
path: root/src/libmime/mime_encoding.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-15 18:25:15 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-15 18:25:15 +0000
commit4d436a67f1c15b4c1e47864a7d7f267162a7da79 (patch)
treef504e902c083d5f4324259c855cfce55047e53e3 /src/libmime/mime_encoding.c
parentc234e5bc9c8b19625009d3925f37875e5fa820d4 (diff)
downloadrspamd-4d436a67f1c15b4c1e47864a7d7f267162a7da79.tar.gz
rspamd-4d436a67f1c15b4c1e47864a7d7f267162a7da79.zip
[Fix] Fix issues found
Diffstat (limited to 'src/libmime/mime_encoding.c')
-rw-r--r--src/libmime/mime_encoding.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c
index 942358d11..17da31f30 100644
--- a/src/libmime/mime_encoding.c
+++ b/src/libmime/mime_encoding.c
@@ -477,30 +477,29 @@ rspamd_mime_charset_utf_enforce (gchar *in, gsize len)
p = in;
end = in + len;
- while (p < end && len > 0 && (err_offset = rspamd_fast_utf8_validate (p, len) > 0)) {
+ while (p < end && len > 0 && (err_offset = rspamd_fast_utf8_validate (p, len)) > 0) {
+ err_offset --; /* As it returns it 1 indexed */
goffset cur_offset = err_offset;
while (cur_offset < len) {
goffset tmp = cur_offset;
- U8_NEXT (in, cur_offset, len, uc);
+ U8_NEXT (p, cur_offset, len, uc);
if (uc > 0) {
/* Fill string between err_offset and tmp with `?` character */
- memset (in + err_offset, '?',
- tmp - err_offset);
+ memset (p + err_offset - 1, '?', tmp - err_offset);
break;
}
}
if (uc < 0) {
/* Fill till the end */
- memset (p + err_offset, '?',
- len - err_offset);
+ memset (p + err_offset, '?', len - err_offset);
break;
}
- p = in + cur_offset;
+ p += cur_offset;
len = end - p;
}
}