changeset 21367:8ebf9edfa432

auth-policy: hashed_password will always be blank, tell buffer it has data so str_len works when converting to hex
author Greg C <bearggg@users.noreply.github.com>
date Wed, 04 Jan 2017 14:02:28 -0800
parents f7f4cb784890
children b26b043c4d82
files src/auth/auth-policy.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-policy.c	Sun Jan 08 18:44:32 2017 +0200
+++ b/src/auth/auth-policy.c	Wed Jan 04 14:02:28 2017 -0800
@@ -438,7 +438,7 @@
 	i_assert(digest != NULL);
 
 	void *ctx = t_malloc(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 @@
 		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);
 	auth_request_var_expand_with_table(context->json, auth_policy_json_template,