dovecot-2.2: imap: If FETCH BINARY fails because of invalid MIME...

dovecot at dovecot.org dovecot at dovecot.org
Fri May 2 08:13:26 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/197f77f6ef0d
changeset: 17302:197f77f6ef0d
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 02 11:06:27 2014 +0300
description:
imap: If FETCH BINARY fails because of invalid MIME part data, return [UNKNOWN-CTE] error.

diffstat:

 src/imap/cmd-fetch.c       |   6 ++++--
 src/imap/imap-fetch-body.c |  21 ++++-----------------
 2 files changed, 8 insertions(+), 19 deletions(-)

diffs (54 lines):

diff -r f9e76b2320c4 -r 197f77f6ef0d src/imap/cmd-fetch.c
--- a/src/imap/cmd-fetch.c	Fri May 02 10:40:12 2014 +0300
+++ b/src/imap/cmd-fetch.c	Fri May 02 11:06:27 2014 +0300
@@ -198,8 +198,10 @@
 		}
 
 		errstr = mailbox_get_last_error(cmd->client->mailbox, &error);
-		if (error == MAIL_ERROR_CONVERSION) {
-			/* BINARY found unsupported Content-Transfer-Encoding */
+		if (error == MAIL_ERROR_CONVERSION ||
+		    error == MAIL_ERROR_INVALIDDATA) {
+			/* a) BINARY found unsupported Content-Transfer-Encoding
+			   b) Content was invalid */
 			tagged_reply = t_strdup_printf(
 				"NO ["IMAP_RESP_CODE_UNKNOWN_CTE"] %s", errstr);
 		} else {
diff -r f9e76b2320c4 -r 197f77f6ef0d src/imap/imap-fetch-body.c
--- a/src/imap/imap-fetch-body.c	Fri May 02 10:40:12 2014 +0300
+++ b/src/imap/imap-fetch-body.c	Fri May 02 11:06:27 2014 +0300
@@ -163,16 +163,8 @@
 		return 1;
 	}
 
-	if (imap_msgpart_open(mail, body->msgpart, &result) < 0) {
-		if (!body->binary ||
-		    mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA)
-			return -1;
-		/* tried to do BINARY fetch for a MIME part with broken
-		   content */
-		str = get_prefix(&ctx->state, body, (uoff_t)-1, FALSE);
-		o_stream_nsend(ctx->client->output, str_data(str), str_len(str));
-		return 1;
-	}
+	if (imap_msgpart_open(mail, body->msgpart, &result) < 0)
+		return -1;
 	ctx->state.cur_input = result.input;
 	ctx->state.cur_size = result.size;
 	ctx->state.cur_size_field = result.size_field;
@@ -197,13 +189,8 @@
 		return 1;
 	}
 
-	if (imap_msgpart_size(mail, body->msgpart, &size) < 0) {
-		if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA)
-			return -1;
-		/* tried to do BINARY.SIZE fetch for a MIME part with broken
-		   content */
-		size = 0;
-	}
+	if (imap_msgpart_size(mail, body->msgpart, &size) < 0)
+		return -1;
 
 	str = t_str_new(128);
 	if (ctx->state.cur_first)


More information about the dovecot-cvs mailing list