]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: policy - Fix crash with auth_policy_check_after_auth=no and delay_until
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 25 Apr 2020 09:30:50 +0000 (12:30 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 4 May 2020 06:57:25 +0000 (06:57 +0000)
The auth policy lookup context must not be allocated from stack, because it
is used in a timeout created by delay_until.

Fixes:
Panic: file auth-request.c: line 292 (auth_request_success_continue): assertion failed: (request->state == AUTH_REQUEST_STATE_MECH_CONTINUE)

src/auth/auth-request.c

index c723c29e345bae1015aa10ad055330b6a0367800..8420c84329fdf7917fd6cdc2be6c31208a4928f2 100644 (file)
@@ -190,14 +190,12 @@ void auth_request_success(struct auth_request *request,
        i_assert(request->state == AUTH_REQUEST_STATE_MECH_CONTINUE);
 
        if (!request->set->policy_check_after_auth) {
-               buffer_t buf;
-               buffer_create_from_const_data(&buf, "", 0);
-               struct auth_policy_check_ctx ctx = {
-                       .success_data = &buf,
-                       .request = request,
-                       .type = AUTH_POLICY_CHECK_TYPE_SUCCESS,
-               };
-               auth_request_policy_check_callback(0, &ctx);
+               struct auth_policy_check_ctx *ctx =
+                       p_new(request->pool, struct auth_policy_check_ctx, 1);
+               ctx->success_data = buffer_create_dynamic(request->pool, 1);
+               ctx->request = request;
+               ctx->type = AUTH_POLICY_CHECK_TYPE_SUCCESS;
+               auth_request_policy_check_callback(0, ctx);
                return;
        }