]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth-policy: hashed_password will always be blank, tell buffer it has data so str_len...
authorGreg C <bearggg@users.noreply.github.com>
Wed, 4 Jan 2017 22:02:28 +0000 (14:02 -0800)
committerGitLab <gitlab@git.dovecot.net>
Sun, 8 Jan 2017 18:33:01 +0000 (20:33 +0200)
src/auth/auth-policy.c

index 75f01ba0234cfa983cc2adea5ed00f3e26c70b12..2849b35808219441b59f825068fd57fa0f43b4e2 100755 (executable)
@@ -438,7 +438,7 @@ void auth_policy_create_json(struct policy_lookup_ctx *context,
        i_assert(digest != NULL);
 
        void *ctx = t_malloc_no0(digest->context_size);
-       string_t *buffer = t_str_new(64);
+       buffer_t *buffer = buffer_create_dynamic(pool_datastack_create(), 64);
 
        digest->init(ctx);
        digest->loop(ctx,
@@ -451,13 +451,13 @@ void auth_policy_create_json(struct policy_lookup_ctx *context,
                digest->loop(ctx, context->request->user, strlen(context->request->user) + 1);
        if (password != NULL)
                digest->loop(ctx, password, strlen(password));
-       ptr = (unsigned char*)str_c_modifiable(buffer);
+       ptr = buffer_get_modifiable_data(buffer, NULL);
        digest->result(ctx, ptr);
-       str_truncate(buffer, digest->digest_size);
+       buffer_set_used_size(buffer, digest->digest_size);
        if (context->set->policy_hash_truncate > 0) {
                buffer_truncate_rshift_bits(buffer, context->set->policy_hash_truncate);
        }
-       const char *hashed_password = binary_to_hex(str_data(buffer), str_len(buffer));
+       const char *hashed_password = binary_to_hex(buffer->data, buffer->used);
        str_append_c(context->json, '{');
        var_table = policy_get_var_expand_table(context->request, hashed_password);
        const char *error;