dovecot-2.2: lib-mail: istream-attachment-extractor handled mixe...

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 29 13:12:15 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/e9f4acfc7ce9
changeset: 17291:e9f4acfc7ce9
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 29 16:03:17 2014 +0300
description:
lib-mail: istream-attachment-extractor handled mixed LFs vs CRLFs correctly.
Unless all the lines have the same newlines, the attachment can't be
recreated back exactly the same.

diffstat:

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

diffs (29 lines):

diff -r 59ada187a702 -r e9f4acfc7ce9 src/lib-mail/istream-attachment-extractor.c
--- a/src/lib-mail/istream-attachment-extractor.c	Tue Apr 29 13:57:44 2014 +0300
+++ b/src/lib-mail/istream-attachment-extractor.c	Tue Apr 29 16:03:17 2014 +0300
@@ -148,6 +148,10 @@
 
 static int astream_base64_decode_lf(struct attachment_istream_part *part)
 {
+	if (part->base64_have_crlf && part->base64_state != BASE64_STATE_CR) {
+		/* mixed LF vs CRLFs */
+		return -1;
+	}
 	part->base64_state = BASE64_STATE_0;
 	if (part->cur_base64_blocks < part->base64_line_blocks) {
 		/* last line */
@@ -212,7 +216,13 @@
 	case BASE64_STATE_CR:
 		if (chr != '\n')
 			return -1;
-		part->base64_have_crlf = TRUE;
+		if (!part->base64_have_crlf) {
+			if (part->base64_line_blocks != 0) {
+				/* mixed LF vs CRLFs */
+				return -1;
+			}
+			part->base64_have_crlf = TRUE;
+		}
 		return astream_base64_decode_lf(part);
 	case BASE64_STATE_EOB:
 		if (chr != '=')


More information about the dovecot-cvs mailing list