changeset 16238:bb25fa35d887

istream-qp-decoder: Fixed assert-crashes caused by recent forced-CRLF q-p change.
author Timo Sirainen <tss@iki.fi>
date Sun, 07 Apr 2013 23:56:01 +0300
parents 73bef641620d
children 57960f02d1bb
files src/lib-mail/istream-qp-decoder.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/istream-qp-decoder.c	Sun Apr 07 23:26:52 2013 +0300
+++ b/src/lib-mail/istream-qp-decoder.c	Sun Apr 07 23:56:01 2013 +0300
@@ -45,15 +45,16 @@
 	if (size == 0)
 		return 0;
 
-	/* the decoded quoted-printable content can never be larger than the
-	   encoded content. at worst they are equal. */
+	/* normally the decoded quoted-printable content can't be larger than
+	   the encoded content, but because we always use CRLFs, it may use
+	   twice as much space by only converting LFs to CRLFs. */
 	i_stream_try_alloc(stream, size, &avail);
 	buffer_avail = stream->buffer_size - stream->pos;
 
-	if (size > buffer_avail) {
+	if (size > buffer_avail/2) {
 		/* can't fit everything to destination buffer.
 		   write as much as we can. */
-		size = buffer_avail;
+		size = buffer_avail/2;
 		if (size == 0)
 			return -2;
 	}