dovecot-2.1: ldap: Crashfixes to previous change.

dovecot at dovecot.org dovecot at dovecot.org
Thu Feb 2 15:25:19 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/7edafe5c43da
changeset: 14052:7edafe5c43da
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 02 15:25:04 2012 +0200
description:
ldap: Crashfixes to previous change.

diffstat:

 src/auth/db-ldap.c |  31 ++++++++++++++++---------------
 src/auth/db-ldap.h |   3 ---
 2 files changed, 16 insertions(+), 18 deletions(-)

diffs (80 lines):

diff -r adb1ac9a9b82 -r 7edafe5c43da src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Thu Feb 02 13:26:38 2012 +0200
+++ b/src/auth/db-ldap.c	Thu Feb 02 15:25:04 2012 +0200
@@ -1027,8 +1027,9 @@
 	}
 }
 
-struct var_expand_table *
-db_ldap_value_get_var_expand_table(struct auth_request *auth_request)
+static struct var_expand_table *
+db_ldap_value_get_var_expand_table(pool_t pool,
+				   struct auth_request *auth_request)
 {
 	const struct var_expand_table *auth_table = NULL;
 	struct var_expand_table *table;
@@ -1038,7 +1039,7 @@
 	for (count = 0; auth_table[count].key != '\0'; count++) ;
 	count++;
 
-	table = t_new(struct var_expand_table, count + 1);
+	table = p_new(pool, struct var_expand_table, count + 2);
 	table[0].key = '$';
 	memcpy(table + 1, auth_table, sizeof(*table) * count);
 	return table;
@@ -1170,30 +1171,30 @@
 {
 	const char *const *values;
 
+	if (ldap_value != NULL)
+		values = ldap_value->values;
+	else {
+		/* LDAP attribute doesn't exist */
+		ctx->val_1_arr[0] = NULL;
+		values = ctx->val_1_arr;
+	}
+
 	if (*field->value == '\0') {
 		/* use the LDAP attribute's value */
-		if (ldap_value != NULL)
-			values = ldap_value->values;
-		else {
-			/* LDAP attribute doesn't exist */
-			ctx->val_1_arr[0] = NULL;
-			values = ctx->val_1_arr;
-		}
 	} else {
 		/* template */
-		if (ldap_value->values[0] != NULL &&
-		    ldap_value->values[1] != NULL) {
+		if (values[0] != NULL && values[1] != NULL) {
 			auth_request_log_warning(ctx->auth_request, "ldap",
 				"Multiple values found for '%s', "
 				"using value '%s'",
-				field->name, ldap_value->values[0]);
+				field->name, values[0]);
 		}
 		if (ctx->var_table == NULL) {
 			ctx->var_table = db_ldap_value_get_var_expand_table(
-							ctx->auth_request);
+						ctx->pool, ctx->auth_request);
 			ctx->var = str_new(ctx->pool, 256);
 		}
-		ctx->var_table[0].value = ldap_value->values[0];
+		ctx->var_table[0].value = values[0];
 		str_truncate(ctx->var, 0);
 		var_expand(ctx->var, field->value, ctx->var_table);
 		ctx->val_1_arr[0] = str_c(ctx->var);
diff -r adb1ac9a9b82 -r 7edafe5c43da src/auth/db-ldap.h
--- a/src/auth/db-ldap.h	Thu Feb 02 13:26:38 2012 +0200
+++ b/src/auth/db-ldap.h	Thu Feb 02 15:25:04 2012 +0200
@@ -177,9 +177,6 @@
 
 void db_ldap_enable_input(struct ldap_connection *conn, bool enable);
 
-struct var_expand_table *
-db_ldap_value_get_var_expand_table(struct auth_request *auth_request);
-
 const char *ldap_escape(const char *str,
 			const struct auth_request *auth_request);
 const char *ldap_get_error(struct ldap_connection *conn);


More information about the dovecot-cvs mailing list