dovecot-2.0: lmtp: Don't allow saving zero byte sized messages.

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 15 21:21:50 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/2c364acbc293
changeset: 12283:2c364acbc293
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Oct 15 19:21:43 2010 +0100
description:
lmtp: Don't allow saving zero byte sized messages.

diffstat:

 src/lmtp/commands.c |  23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diffs (61 lines):

diff -r 7a839a028dfa -r 2c364acbc293 src/lmtp/commands.c
--- a/src/lmtp/commands.c	Fri Oct 15 19:04:42 2010 +0100
+++ b/src/lmtp/commands.c	Fri Oct 15 19:21:43 2010 +0100
@@ -526,7 +526,7 @@
 	return FALSE;
 }
 
-static void client_rcpt_fail_all(struct client *client)
+static void client_rcpt_tempfail_all(struct client *client)
 {
 	const struct mail_recipient *rcpt;
 
@@ -583,7 +583,6 @@
 		i_error("Can't open delivery mail as raw: %s",
 			mail_storage_get_last_error(box->storage, &error));
 		mailbox_free(&box);
-		client_rcpt_fail_all(client);
 		return -1;
 	}
 	raw_box = (struct raw_mailbox *)box;
@@ -605,8 +604,10 @@
 	struct mail *src_mail;
 	uid_t old_uid, first_uid = (uid_t)-1;
 
-	if (client_open_raw_mail(client, input) < 0)
+	if (client_open_raw_mail(client, input) < 0) {
+		client_rcpt_tempfail_all(client);
 		return;
+	}
 
 	old_uid = geteuid();
 	src_mail = client->state.raw_mail;
@@ -707,12 +708,28 @@
 	return str_c(str);
 }
 
+static void client_rcpt_fail_all_zerosize(struct client *client)
+{
+	const struct mail_recipient *rcpt;
+
+	array_foreach(&client->state.rcpt_to, rcpt) {
+		client_send_line(client,
+				 "451 4.2.0 <%s> Can't save empty message",
+				 rcpt->address);
+	}
+}
+
 static bool client_input_data_write(struct client *client)
 {
 	struct istream *input;
 	bool ret = TRUE;
 
 	i_stream_destroy(&client->dot_input);
+	if (client->state.mail_data_output == NULL &&
+	    client->state.mail_data->used == 0) {
+		client_rcpt_fail_all_zerosize(client);
+		return TRUE;
+	}
 
 	input = client_get_input(client);
 	client_input_data_write_local(client, input);


More information about the dovecot-cvs mailing list