1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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
This commit is contained in:
Andrew Bartlett 2013-07-30 10:40:39 +12:00 committed by Stefan Metzmacher
parent ba40d0d9d3
commit 859182da6d

View File

@ -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);