dovecot-2.2: ldap: Don't crash if attributes have no @subrequests.

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 25 17:57:00 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/3de93139afce
changeset: 16111:3de93139afce
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 25 17:56:53 2013 +0200
description:
ldap: Don't crash if attributes have no @subrequests.

diffstat:

 src/auth/db-ldap.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (39 lines):

diff -r c51873a8e0d9 -r 3de93139afce src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Mon Mar 25 17:02:15 2013 +0200
+++ b/src/auth/db-ldap.c	Mon Mar 25 17:56:53 2013 +0200
@@ -806,11 +806,13 @@
 		if (srequest->result != NULL)
 			ldap_msgfree(srequest->result);
 
-		array_foreach(&srequest->named_results, named_res) {
-			if (named_res->result == res)
-				res = NULL;
-			if (named_res->result != NULL)
-				ldap_msgfree(named_res->result);
+		if (array_is_created(&srequest->named_results)) {
+			array_foreach(&srequest->named_results, named_res) {
+				if (named_res->result == res)
+					res = NULL;
+				if (named_res->result != NULL)
+					ldap_msgfree(named_res->result);
+			}
 		}
 	}
 	if (res != NULL)
@@ -1449,10 +1451,12 @@
 		ctx->debug = t_str_new(256);
 
 	get_ldap_fields(ctx, conn, ldap_request->result, "");
-	array_foreach(&ldap_request->named_results, named_res) {
-		suffix = t_strdup_printf("@%s", named_res->field->name);
-		if (named_res->result != NULL)
-			get_ldap_fields(ctx, conn, named_res->result, suffix);
+	if (array_is_created(&ldap_request->named_results)) {
+		array_foreach(&ldap_request->named_results, named_res) {
+			suffix = t_strdup_printf("@%s", named_res->field->name);
+			if (named_res->result != NULL)
+				get_ldap_fields(ctx, conn, named_res->result, suffix);
+		}
 	}
 	return ctx;
 }


More information about the dovecot-cvs mailing list