From 1d2b6e8712b40be1a9f68aee63ef7ca448a14ccb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 Jul 2006 01:59:43 +0000 Subject: r16846: Try not to segfault if the domain SID isn't there, or the search failed. Andrew Bartlett (This used to be commit 5d5d49374fcbe0a42108c5bb2f2f44abc05e9bb9) --- source4/passdb/secrets.c | 20 ++++++++++++++------ 1 file 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; } -- cgit