]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: message_snippet_generate() - Fix potential crash when input ends with '>'
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 15 Jan 2020 20:10:08 +0000 (22:10 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 23 Jan 2020 18:11:14 +0000 (20:11 +0200)
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

src/lib-mail/message-snippet.c

index 560e499b04f1640ebd649fa1ce39bf85d85637d1..a3cc319d33427dea591c564238c69116be98e0ce 100644 (file)
@@ -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))) {