summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2013-07-30 10:40:39 +1200
committerStefan Metzmacher <metze@samba.org>2013-08-02 13:11:20 +0200
commit859182da6d06be0e9d37d7ed3448efc3dc78bdb2 (patch)
tree103bb2022932b09af7c8397adaaa3b5113e58940
parentba40d0d9d320e500621a6a8107a2ef0a34aeb6ba (diff)
downloadsamba-859182da6d06be0e9d37d7ed3448efc3dc78bdb2.tar.gz
samba-859182da6d06be0e9d37d7ed3448efc3dc78bdb2.tar.bz2
samba-859182da6d06be0e9d37d7ed3448efc3dc78bdb2.zip
dfs_server: Use dsdb_search_one to catch 0 results as well as NO_SUCH_OBJECT errors
This ensures we do not de-reference an invalid rs->msgs pointer if the pointed-to object was not objectclass=computer Andrew Bartlett Bug: https://bugzilla.samba.org/show_bug.cgi?id=10052 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Aug 2 13:11:20 CEST 2013 on sn-devel-104
-rw-r--r--dfs_server/dfs_server_ad.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c
index 249a1d1861..062eb495ec 100644
--- a/dfs_server/dfs_server_ad.c
+++ b/dfs_server/dfs_server_ad.c
@@ -206,14 +206,14 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb,
for (i = 0; i<r->count; i++) {
struct ldb_dn *dn;
- struct ldb_result *r2;
+ struct ldb_message *msg;
dn = ldb_msg_find_attr_as_dn(ldb, ctx, r->msgs[i], "serverReference");
if (!dn) {
return NT_STATUS_INTERNAL_ERROR;
}
- ret = ldb_search(ldb, r, &r2, dn, LDB_SCOPE_BASE, attrs2, "(objectClass=computer)");
+ ret = dsdb_search_one(ldb, r, &msg, dn, LDB_SCOPE_BASE, attrs2, 0, "(objectClass=computer)");
if (ret != LDB_SUCCESS) {
DEBUG(2,(__location__ ": Search for computer on %s failed - %s\n",
ldb_dn_get_linearized(dn), ldb_errstring(ldb)));
@@ -221,7 +221,7 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb,
}
if (dofqdn) {
- const char *dns = ldb_msg_find_attr_as_string(r2->msgs[0], "dNSHostName", NULL);
+ const char *dns = ldb_msg_find_attr_as_string(msg, "dNSHostName", NULL);
if (dns == NULL) {
DEBUG(2,(__location__ ": dNSHostName missing on %s\n",
ldb_dn_get_linearized(dn)));
@@ -233,7 +233,7 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb,
NT_STATUS_HAVE_NO_MEMORY_AND_FREE(list->names[list->count], r);
} else {
char *tmp;
- const char *aname = ldb_msg_find_attr_as_string(r2->msgs[0], "sAMAccountName", NULL);
+ const char *aname = ldb_msg_find_attr_as_string(msg, "sAMAccountName", NULL);
if (aname == NULL) {
DEBUG(2,(__location__ ": sAMAccountName missing on %s\n",
ldb_dn_get_linearized(dn)));
@@ -250,7 +250,7 @@ static NTSTATUS get_dcs_insite(TALLOC_CTX *ctx, struct ldb_context *ldb,
list->names[list->count] = tmp;
}
list->count++;
- talloc_free(r2);
+ talloc_free(msg);
}
talloc_free(r);