]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Check bounds
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Apr 2017 12:22:58 +0000 (13:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Apr 2017 12:22:58 +0000 (13:22 +0100)
src/libmime/mime_encoding.c

index 5f13c108640868ffabf6a14bbae28030d6ec609c..440dff35df698dba0e87a6267ae8552b3c4022ad 100644 (file)
@@ -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) {