From 4b592e861be73eace3ddc1afeaa68eb79f28474d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 7 Apr 2017 13:22:58 +0100 Subject: [PATCH] [Minor] Check bounds --- src/libmime/mime_encoding.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libmime/mime_encoding.c b/src/libmime/mime_encoding.c index 5f13c1086..440dff35d 100644 --- a/src/libmime/mime_encoding.c +++ b/src/libmime/mime_encoding.c @@ -341,6 +341,13 @@ rspamd_mime_charset_utf_enforce (gchar *in, gsize len) while (remain > 0 && !g_utf8_validate (p, remain, &end)) { gchar *valid; + if (end >= in + len) { + if (p < in + len) { + memset ((gchar *)p, '?', (in + len) - p); + } + break; + } + valid = g_utf8_find_next_char (end, in + len); if (!valid) { -- 2.39.5