]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict: dict-fs - Allocate key from iteration pool
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 6 Oct 2023 06:24:38 +0000 (09:24 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 9 Oct 2023 11:16:26 +0000 (14:16 +0300)
Path gets allocated from stack memory, which causes it to
become invalidated before used by clients.

Broken in 32e8bd5b5a9d5bc04e5ac6c65ac132ba5c386d64

src/lib-dict-extra/dict-fs.c

index f9c3750b09ac8eca50894a291c89bad476c73ee5..9ba9d0be1db48904f439a45627b043c4567a2ba2 100644 (file)
@@ -204,12 +204,12 @@ static bool fs_dict_iterate(struct dict_iterate_context *ctx,
        }
        iter->key_count++;
 
-       path = t_strconcat(iter->path, *key_r, NULL);
+       p_clear(iter->value_pool);
+       path = p_strconcat(iter->value_pool, iter->path, *key_r, NULL);
        if ((iter->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0) {
                *key_r = path;
                return TRUE;
        }
-       p_clear(iter->value_pool);
        struct dict_op_settings set = {
                .username = ctx->set.username,
        };