From bdcbf7aa2db8dd9acfd8fd1c08b7909de5106760 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 27 Sep 2019 10:47:34 +0100 Subject: [PATCH] [Minor] Fix OOB access --- src/libmime/mime_parser.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libmime/mime_parser.c b/src/libmime/mime_parser.c index 1153a54c7..1c132335c 100644 --- a/src/libmime/mime_parser.c +++ b/src/libmime/mime_parser.c @@ -927,17 +927,19 @@ rspamd_mime_preprocess_cb (struct rspamd_multipattern *mp, bend ++; } - if (*bend == '\r') { - bend ++; + if (bend < end) { + if (*bend == '\r') { + bend++; - /* \r\n */ - if (*bend == '\n') { - bend ++; + /* \r\n */ + if (*bend == '\n') { + bend++; + } + } + else { + /* \n */ + bend++; } - } - else { - /* \n */ - bend ++; } b.boundary = p - st->start - 2; -- 2.39.5