commit 95106e8: [Minor] Fix rare case of off-by-one read

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Nov 24 12:07:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-11-24 12:06:19 +0000
URL: https://github.com/rspamd/rspamd/commit/95106e8145ad6feb3518772df36bc508d442c65c (HEAD -> master)

[Minor] Fix rare case of off-by-one read

---
 src/libmime/message.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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;


More information about the Commits mailing list