From 0b5e7b1ac35040d2040709b7cceddba7e69866e6 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Thu, 28 Oct 2021 00:40:58 +0200 Subject: [PATCH] lib-sieve: sieve-result - Fix panic occurring upon temp fail after committed keep-equivalent action. The determination of whether a keep-equivalent action was already executed is performed in sieve_result_implicit_keep_execute(), which can also be called from sieve_result_implicit_keep_finalize(). But there, the keep-equivalent status was checked before any call to sieve_result_implicit_keep_execute(), which would thus yield the wrong result. This change also makes the associated debug message more specific (otherwise two identical debug messages are logged) and an assert is added that makes sure the keep-equivalent action is actually finalized when the implicit keep was supposed to be finalized. Panic was: Panic: file sieve-result.c: line 1706 (sieve_result_implicit_keep_finalize): assertion failed: (aexec_keep->state == SIEVE_ACTION_EXECUTION_STATE_EXECUTED) --- src/lib-sieve/sieve-result.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c index 358491394..89d249e48 100644 --- a/src/lib-sieve/sieve-result.c +++ b/src/lib-sieve/sieve-result.c @@ -1662,15 +1662,6 @@ sieve_result_implicit_keep_finalize(struct sieve_result_execution *rexec) break; } - if (rexec->keep_equiv_action != NULL) { - struct sieve_action_execution *ke_aexec = - rexec->keep_equiv_action; - - e_debug(rexec->event, "No implicit keep needed " - "(equivalent %s action already executed)", - sieve_action_name(&ke_aexec->action->action)); - return ke_aexec->status; - } if ((eenv->flags & SIEVE_EXECUTE_FLAG_DEFER_KEEP) != 0) { e_debug(rexec->event, "Execution of implicit keep is deferred"); return rexec->keep_status; @@ -1700,6 +1691,19 @@ sieve_result_implicit_keep_finalize(struct sieve_result_execution *rexec) if (act_keep->def == NULL) return rexec->keep_status; + if (rexec->keep_equiv_action != NULL) { + struct sieve_action_execution *ke_aexec = + rexec->keep_equiv_action; + + i_assert(ke_aexec->state >= + SIEVE_ACTION_EXECUTION_STATE_FINALIZED); + + e_debug(rexec->event, "No implicit keep needed " + "(equivalent %s action already finalized)", + sieve_action_name(&ke_aexec->action->action)); + return ke_aexec->status; + } + e_debug(rexec->event, "Finalize implicit keep (status=%s)", sieve_execution_exitcode_to_str(rexec->status)); -- GitLab