From: Douglas Bagnall Date: Wed, 10 Apr 2019 04:43:10 +0000 (+1200) Subject: s4/lib/policy/gp_ldap: use ldb API to find messages X-Git-Tag: tdb-1.4.1~91 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d0f9491131e03cd33dc8a2161b86ceb22c678ab;p=thirdparty%2Fsamba.git s4/lib/policy/gp_ldap: use ldb API to find messages Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/source4/lib/policy/gp_ldap.c b/source4/lib/policy/gp_ldap.c index 5a1ee7d8ed6..67b329b1295 100644 --- a/source4/lib/policy/gp_ldap.c +++ b/source4/lib/policy/gp_ldap.c @@ -398,7 +398,7 @@ NTSTATUS gp_get_gplinks(struct gp_context *gp_ctx, const char *dn_str, struct gp struct gp_link **gplinks; char *gplink_str; int rv; - unsigned int i, j; + unsigned int i; NTSTATUS status; /* Create a forked memory context, as a base for everything here */ @@ -415,18 +415,18 @@ NTSTATUS gp_get_gplinks(struct gp_context *gp_ctx, const char *dn_str, struct gp } for (i = 0; i < result->count; i++) { - for (j = 0; j < result->msgs[i]->num_elements; j++) { - struct ldb_message_element *element = &result->msgs[i]->elements[j]; - - if (strcmp(element->name, "gPLink") == 0) { - SMB_ASSERT(element->num_values > 0); - gplink_str = talloc_strdup(mem_ctx, (char *) element->values[0].data); - if (gplink_str == NULL) { - TALLOC_FREE(mem_ctx); - return NT_STATUS_NO_MEMORY; - } - goto found; + struct ldb_message_element *element = \ + ldb_msg_find_element(result->msgs[i], "gPLink"); + if (element != NULL) { + SMB_ASSERT(element->num_values > 0); + gplink_str = talloc_strdup( + mem_ctx, + (char *) element->values[0].data); + if (gplink_str == NULL) { + TALLOC_FREE(mem_ctx); + return NT_STATUS_NO_MEMORY; } + goto found; } } gplink_str = talloc_strdup(mem_ctx, "");