dovecot-2.2: ldap: Various crashfixes

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 25 18:10:23 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/a6f8c4d6252e
changeset: 16112:a6f8c4d6252e
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 25 18:10:16 2013 +0200
description:
ldap: Various crashfixes

diffstat:

 src/auth/db-ldap.c     |  25 +++++++++++++++++++------
 src/auth/db-ldap.h     |   2 ++
 src/auth/userdb-ldap.c |   1 +
 3 files changed, 22 insertions(+), 6 deletions(-)

diffs (72 lines):

diff -r 3de93139afce -r a6f8c4d6252e src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Mon Mar 25 17:56:53 2013 +0200
+++ b/src/auth/db-ldap.c	Mon Mar 25 18:10:16 2013 +0200
@@ -752,7 +752,7 @@
 			ldap_err2string(ret));
 		res = NULL;
 	}
-	if (ret == LDAP_SUCCESS && srequest != NULL) {
+	if (ret == LDAP_SUCCESS && srequest != NULL && !srequest->multi_entry) {
 		/* expand any @results */
 		if (!final_result) {
 			if (db_ldap_search_save_result(srequest, res) < 0) {
@@ -779,11 +779,22 @@
 		aqueue_delete(conn->request_queue, idx);
 	}
 
-	T_BEGIN {
-		if (res != NULL && srequest != NULL && srequest->result != NULL)
-			request->callback(conn, request, srequest->result);
-		request->callback(conn, request, res);
-	} T_END;
+	if (srequest == NULL) {
+		T_BEGIN {
+			request->callback(conn, request, res);
+		} T_END;
+	} else {
+		T_BEGIN {
+			LDAPMessage *orig_result = srequest->result;
+
+			if (res != NULL && srequest->result != NULL)
+				request->callback(conn, request, srequest->result);
+
+			srequest->result = res;
+			request->callback(conn, request, res);
+			srequest->result = orig_result;
+		} T_END;
+	}
 
 	if (idx > 0) {
 		/* see if there are timed out requests */
@@ -1440,6 +1451,8 @@
 	const char *suffix;
 	pool_t pool;
 
+	i_assert(ldap_request->result != NULL);
+
 	pool = pool_alloconly_create("ldap result iter", 1024);
 	ctx = p_new(pool, struct db_ldap_result_iterate_context, 1);
 	ctx->pool = pool;
diff -r 3de93139afce -r a6f8c4d6252e src/auth/db-ldap.h
--- a/src/auth/db-ldap.h	Mon Mar 25 17:56:53 2013 +0200
+++ b/src/auth/db-ldap.h	Mon Mar 25 18:10:16 2013 +0200
@@ -122,6 +122,8 @@
 	LDAPMessage *result;
 	ARRAY(struct ldap_request_named_result) named_results;
 	unsigned int name_idx;
+
+	bool multi_entry;
 };
 
 struct ldap_request_bind {
diff -r 3de93139afce -r a6f8c4d6252e src/auth/userdb-ldap.c
--- a/src/auth/userdb-ldap.c	Mon Mar 25 17:56:53 2013 +0200
+++ b/src/auth/userdb-ldap.c	Mon Mar 25 18:10:16 2013 +0200
@@ -221,6 +221,7 @@
 	request->request.filter = p_strdup(auth_request->pool, str_c(str));
 	request->request.attr_map = &conn->iterate_attr_map;
 	request->request.attributes = conn->iterate_attr_names;
+	request->request.multi_entry = TRUE;
 
 	if (global_auth_settings->debug) {
 		i_debug("ldap: iterate: base=%s scope=%s filter=%s fields=%s",


More information about the dovecot-cvs mailing list