changeset 11131:6b7b2987c41f HEAD

lmtp: Crashfix to multiple RCPT TOs when the first mail couldn't be used as a copy source.
author Timo Sirainen <tss@iki.fi>
date Mon, 12 Apr 2010 19:14:55 +0300
parents a73f3da6d7a8
children 3d585e69aa95
files src/lmtp/commands.c
diffstat 1 files changed, 10 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/lmtp/commands.c	Mon Apr 12 10:59:39 2010 +0300
+++ b/src/lmtp/commands.c	Mon Apr 12 19:14:55 2010 +0300
@@ -604,26 +604,19 @@
 	if (client_open_raw_mail(client, input) < 0)
 		return;
 
-	/* save the message to the first recipient's mailbox */
 	src_mail = client->state.raw_mail;
-	if (!client_deliver_next(client, src_mail)) {
-		/* nothing got saved */
-		i_assert(client->state.first_saved_mail == NULL);
-		return;
+	while (client_deliver_next(client, src_mail)) {
+		if (client->state.first_saved_mail == NULL ||
+		    client->state.first_saved_mail == src_mail)
+			mail_user_unref(&client->state.dest_user);
+		else {
+			/* use the first saved message to save it elsewhere too.
+			   this might allow hard linking the files. */
+			client->state.dest_user = NULL;
+			src_mail = client->state.first_saved_mail;
+		}
 	}
 
-	if (client->state.first_saved_mail == NULL)
-		mail_user_unref(&client->state.dest_user);
-	else {
-		client->state.dest_user = NULL;
-		src_mail = client->state.first_saved_mail;
-	}
-
-	/* use the first saved message to save it elsewhere too.
-	   this might allow hard linking the files. */
-	while (client_deliver_next(client, src_mail))
-		mail_user_unref(&client->state.dest_user);
-
 	if (client->state.first_saved_mail != NULL) {
 		struct mail *mail = client->state.first_saved_mail;
 		struct mailbox_transaction_context *trans = mail->transaction;