]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: transaction: Prevent early transaction abort in smtp_client_transac...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Wed, 15 Aug 2018 20:39:58 +0000 (22:39 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Wed, 6 Feb 2019 08:08:52 +0000 (10:08 +0200)
Can happen in one of the command callbacks of aborted commands.

src/lib-smtp/smtp-client-private.h
src/lib-smtp/smtp-client-transaction.c

index 1e5dc0d0ba6c4217df222abb995f2936341354e5..4f9c02dc26f5c6bd81c7421eb37e2d23e85ffd40 100644 (file)
@@ -103,6 +103,7 @@ struct smtp_client_transaction {
 
        bool data_provided:1;
        bool finished:1;
+       bool failing:1;
        bool submitted_data:1;
 };
 
index 5e4a619046f253f0b6f7e94c11246ae81d43d071..95a06eedae472f86f8f00bc56ce9da6df5793998 100644 (file)
@@ -216,6 +216,9 @@ void smtp_client_transaction_abort(struct smtp_client_transaction *trans)
        struct smtp_client_transaction_rcpt **rcpts;
        unsigned int i, count;
 
+       if (trans->failing)
+               return;
+
        smtp_client_transaction_debug(trans, "Abort");
 
        /* clean up */
@@ -313,6 +316,8 @@ void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans,
                reply = trans->failure;
        i_assert(reply != NULL);
 
+       trans->failing = TRUE;
+
        smtp_client_transaction_debug(trans,
                "Returning failure: %s", smtp_reply_log(reply));
 
@@ -386,6 +391,8 @@ void smtp_client_transaction_fail_reply(struct smtp_client_transaction *trans,
                smtp_client_command_abort(&trans->cmd_plug);
        trans->cmd_plug = NULL;
 
+       trans->failing = FALSE;
+
        if (trans->data_provided) {
                /* abort the transaction only if smtp_client_transaction_send()
                   was called (and if it is not aborted already) */