dovecot-2.2: istream-attachment-extractor: Fixed handling attach...

dovecot at dovecot.org dovecot at dovecot.org
Sun Jun 16 21:08:52 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/9dcbcc0871f0
changeset: 16519:9dcbcc0871f0
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Jun 16 21:08:40 2013 +0300
description:
istream-attachment-extractor: Fixed handling attachment as the message body without MIME.
Don't crash at the end after parsing the base64 data.

diffstat:

 src/lib-mail/istream-attachment-extractor.c |  8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r c290383e60da -r 9dcbcc0871f0 src/lib-mail/istream-attachment-extractor.c
--- a/src/lib-mail/istream-attachment-extractor.c	Sun Jun 16 20:15:42 2013 +0300
+++ b/src/lib-mail/istream-attachment-extractor.c	Sun Jun 16 21:08:40 2013 +0300
@@ -524,6 +524,7 @@
 astream_end_of_part(struct attachment_istream *astream)
 {
 	struct attachment_istream_part *part = &astream->part;
+	size_t old_size;
 	int ret = 0;
 
 	/* MIME part changed. we're now parsing the end of a boundary,
@@ -540,8 +541,15 @@
 		}
 		break;
 	case MAIL_ATTACHMENT_STATE_YES:
+		old_size = astream->istream.pos - astream->istream.skip;
 		if (astream_part_finish(astream) < 0)
 			ret = -1;
+		else {
+			/* finished base64 may have added a few more trailing
+			   bytes to the stream */
+			ret = astream->istream.pos -
+				astream->istream.skip - old_size;
+		}
 		break;
 	}
 	part->state = MAIL_ATTACHMENT_STATE_NO;


More information about the dovecot-cvs mailing list