From: Vsevolod Stakhov Date: Fri, 7 Apr 2017 12:22:58 +0000 (+0100) Subject: [Minor] Check bounds X-Git-Tag: 1.5.5~24 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4b592e861be73eace3ddc1afeaa68eb79f28474d;p=rspamd.git [Minor] Check bounds --- 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) {