From: Vsevolod Stakhov Date: Tue, 24 Nov 2020 12:06:19 +0000 (+0000) Subject: [Minor] Fix rare case of off-by-one read X-Git-Tag: 2.7~118 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=95106e8145ad6feb3518772df36bc508d442c65c;p=rspamd.git [Minor] Fix rare case of off-by-one read --- diff --git a/src/libmime/message.c b/src/libmime/message.c index 411b872c9..10de8ce53 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -275,7 +275,16 @@ rspamd_strip_newlines_parse (struct rspamd_task *task, } } - if (G_UNLIKELY (*p) == '\r') { + if (G_UNLIKELY (p >= pe)) { + /* + * This is reached when there is a utf8 part and we + * have zero width spaces at the end of the text + * So we just check overflow and refuse to access *p if it is + * after our real content. + */ + break; + } + else if (G_UNLIKELY (*p) == '\r') { switch (state) { case normal_char: state = seen_cr;