Mercurial > dovecot > core-2.2
changeset 20881:95822083a88b
lib-mail: Fixed infinite loop in istream-attachment-extractor
Broken by 7f74811b7. Pretty much any larger attachment going through
this istream had a good potential of going into an infinite loop.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 17 Oct 2016 23:06:48 +0300 |
parents | 59a3ab804bcc |
children | 834cc4ef561b |
files | src/lib-mail/istream-attachment-extractor.c |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/istream-attachment-extractor.c Mon Oct 17 10:59:34 2016 +0300 +++ b/src/lib-mail/istream-attachment-extractor.c Mon Oct 17 23:06:48 2016 +0300 @@ -375,7 +375,9 @@ o_stream_cork(output); hash_format_reset(astream->set.hash_format); - while ((ret = i_stream_read_more(base64_input, &data, &size)) > 0) { + size_t bytes_needed = 1; + while ((ret = i_stream_read_bytes(base64_input, &data, &size, + bytes_needed)) > 0) { buffer_set_used_size(buf, 0); if (base64_decode(data, size, &size, buf) < 0) { i_error("istream-attachment: BUG: " @@ -387,6 +389,7 @@ o_stream_nsend(output, buf->data, buf->used); hash_format_loop(astream->set.hash_format, buf->data, buf->used); + bytes_needed = i_stream_get_data_size(base64_input) + 1; } if (ret != -1) { i_assert(failed);