diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-11-24 12:06:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-11-24 12:06:40 +0000 |
commit | 95106e8145ad6feb3518772df36bc508d442c65c (patch) | |
tree | 4461857398f99d836f8a0b521a5954a66e070765 /src/libmime/message.c | |
parent | 132b2f7a7d67fe6a638bfbfdd3fe60da63435d0c (diff) | |
download | rspamd-95106e8145ad6feb3518772df36bc508d442c65c.tar.gz rspamd-95106e8145ad6feb3518772df36bc508d442c65c.zip |
[Minor] Fix rare case of off-by-one read
Diffstat (limited to 'src/libmime/message.c')
-rw-r--r-- | src/libmime/message.c | 11 |
1 files changed, 10 insertions, 1 deletions
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; |