From: Timo Sirainen Date: Wed, 15 Jan 2020 20:10:08 +0000 (+0200) Subject: lib-mail: message_snippet_generate() - Fix potential crash when input ends with '>' X-Git-Tag: 2.3.9.3~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3a55f35c208b5fd3d52c0a6272bd5b8717a2ae54;p=thirdparty%2Fdovecot%2Fcore.git lib-mail: message_snippet_generate() - Fix potential crash when input ends with '>' This happens only when the mail was large enough and full enough with whitespace that message-parser returned multiple blocks before the snippet was finished. Broken by 74063ed8219d055489d5233b0c02a59886d2078c --- diff --git a/src/lib-mail/message-snippet.c b/src/lib-mail/message-snippet.c index 560e499b04..a3cc319d33 100644 --- a/src/lib-mail/message-snippet.c +++ b/src/lib-mail/message-snippet.c @@ -40,6 +40,8 @@ static void snippet_add_content(struct snippet_context *ctx, size_t *count_r) { i_assert(target != NULL); + if (size == 0) + return; if (size >= 3 && ((data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) || (data[0] == 0xBF && data[1] == 0xBB && data[2] == 0xEF))) {