dovecot-2.1: auth ldap: Previous change broke %$ variable.

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 24 17:03:53 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/4d82c74f702c
changeset: 14733:4d82c74f702c
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 24 17:03:42 2012 +0300
description:
auth ldap: Previous change broke %$ variable.

diffstat:

 src/auth/auth-request.c |  17 ++++++++++++-----
 src/auth/db-ldap.c      |   4 ++--
 2 files changed, 14 insertions(+), 7 deletions(-)

diffs (53 lines):

diff -r 18c8d840b028 -r 4d82c74f702c src/auth/auth-request.c
--- a/src/auth/auth-request.c	Mon Sep 24 16:49:29 2012 +0300
+++ b/src/auth/auth-request.c	Mon Sep 24 17:03:42 2012 +0300
@@ -1799,15 +1799,22 @@
 				       auth_request_escape_func_t *escape_func,
 				       unsigned int *count)
 {
-	struct var_expand_table *tab;
+	const unsigned int auth_count =
+		N_ELEMENTS(auth_request_var_expand_static_tab);
+	struct var_expand_table *tab, *ret_tab;
 
 	if (escape_func == NULL)
 		escape_func = escape_none;
 
-	*count += N_ELEMENTS(auth_request_var_expand_static_tab);
-	tab = t_malloc(*count * sizeof(struct var_expand_table));
+	/* keep the extra fields at the beginning. the last static_tab field
+	   contains the ending NULL-fields. */
+	tab = ret_tab = t_malloc((*count + auth_count) * sizeof(*tab));
+	memset(tab, 0, *count * sizeof(*tab));
+	tab += *count;
+	*count += auth_count;
+
 	memcpy(tab, auth_request_var_expand_static_tab,
-	       sizeof(auth_request_var_expand_static_tab));
+	       auth_count * sizeof(*tab));
 
 	tab[0].value = escape_func(auth_request->user, auth_request);
 	tab[1].value = escape_func(t_strcut(auth_request->user, '@'),
@@ -1854,7 +1861,7 @@
 	}
 	tab[18].value = auth_request->session_id == NULL ? NULL :
 		escape_func(auth_request->session_id, auth_request);
-	return tab;
+	return ret_tab;
 }
 
 const struct var_expand_table *
diff -r 18c8d840b028 -r 4d82c74f702c src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Mon Sep 24 16:49:29 2012 +0300
+++ b/src/auth/db-ldap.c	Mon Sep 24 17:03:42 2012 +0300
@@ -1076,8 +1076,8 @@
 
 	table = auth_request_get_var_expand_table_full(auth_request, NULL,
 						       &count);
-	table[count-1].key = '$';
-	table[count-1].value = ldap_value;
+	table[0].key = '$';
+	table[0].value = ldap_value;
 	return table;
 }
 


More information about the dovecot-cvs mailing list