summaryrefslogtreecommitdiff
path: root/source4/passdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-07-07 01:59:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:52 -0500
commit1d2b6e8712b40be1a9f68aee63ef7ca448a14ccb (patch)
treebacc4c1ecb26d8a12873ee7c2ba9de942ffda598 /source4/passdb
parentec3be5b90888aabddd15dcc1410ad3f69196810d (diff)
downloadsamba-1d2b6e8712b40be1a9f68aee63ef7ca448a14ccb.tar.gz
samba-1d2b6e8712b40be1a9f68aee63ef7ca448a14ccb.tar.bz2
samba-1d2b6e8712b40be1a9f68aee63ef7ca448a14ccb.zip
r16846: Try not to segfault if the domain SID isn't there, or the search
failed. Andrew Bartlett (This used to be commit 5d5d49374fcbe0a42108c5bb2f2f44abc05e9bb9)
Diffstat (limited to 'source4/passdb')
-rw-r--r--source4/passdb/secrets.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/source4/passdb/secrets.c b/source4/passdb/secrets.c
index 8f4b5f4f5e..7171fa11ab 100644
--- a/source4/passdb/secrets.c
+++ b/source4/passdb/secrets.c
@@ -136,7 +136,7 @@ struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
ldb = secrets_db_connect(mem_ctx);
if (ldb == NULL) {
DEBUG(5, ("secrets_db_connect failed\n"));
- goto done;
+ return NULL;
}
ldb_ret = gendb_search(ldb, ldb,
@@ -144,25 +144,33 @@ struct dom_sid *secrets_get_domain_sid(TALLOC_CTX *mem_ctx,
&msgs, attrs,
SECRETS_PRIMARY_DOMAIN_FILTER, domain);
+ if (ldb_ret == -1) {
+ DEBUG(5, ("Error searching for domain SID for %s: %s",
+ domain, ldb_errstring(ldb)));
+ talloc_free(ldb);
+ return NULL;
+ }
+
if (ldb_ret == 0) {
DEBUG(5, ("Did not find domain record for %s\n", domain));
- goto done;
+ talloc_free(ldb);
+ return NULL;
}
if (ldb_ret > 1) {
DEBUG(5, ("Found more than one (%d) domain records for %s\n",
ldb_ret, domain));
- goto done;
+ talloc_free(ldb);
+ return NULL;
}
result = samdb_result_dom_sid(mem_ctx, msgs[0], "objectSid");
if (result == NULL) {
DEBUG(0, ("Domain object for %s does not contain a SID!\n",
domain));
- goto done;
+ talloc_free(ldb);
+ return NULL;
}
- done:
- talloc_free(ldb);
return result;
}