diff --git a/source/groupdb/mapping_ldb.c b/source/groupdb/mapping_ldb.c index 68e5b4c..92b2934 100644 --- a/source/groupdb/mapping_ldb.c +++ b/source/groupdb/mapping_ldb.c @@ -222,10 +222,10 @@ static bool get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map) if (dn == NULL) goto failed; ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res); - talloc_steal(dn, res); - if (ret != LDB_SUCCESS || res->count != 1) { + if (ret != LDB_SUCCESS || res == NULL || res->count != 1) { goto failed; } + talloc_steal(dn, res); if (!msg_to_group_map(res->msgs[0], map)) goto failed; @@ -251,8 +251,8 @@ static bool get_group_map_from_gid(gid_t gid, GROUP_MAP *map) if (expr == NULL) goto failed; ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res); + if (ret != LDB_SUCCESS || res == NULL || res->count != 1) goto failed; talloc_steal(expr, res); - if (ret != LDB_SUCCESS || res->count != 1) goto failed; if (!msg_to_group_map(res->msgs[0], map)) goto failed; @@ -277,8 +277,8 @@ static bool get_group_map_from_ntname(const char *name, GROUP_MAP *map) if (expr == NULL) goto failed; ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res); + if (ret != LDB_SUCCESS || res == NULL || res->count != 1) goto failed; talloc_steal(expr, res); - if (ret != LDB_SUCCESS || res->count != 1) goto failed; if (!msg_to_group_map(res->msgs[0], map)) goto failed; @@ -343,7 +343,7 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_ ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, NULL, &res); talloc_steal(tmp_ctx, res); - if (ret != LDB_SUCCESS) goto failed; + if (ret != LDB_SUCCESS || res == NULL) goto failed; (*pp_rmap) = NULL; *p_num_entries = 0; @@ -396,7 +396,7 @@ static NTSTATUS one_alias_membership(const DOM_SID *member, ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, attrs, &res); talloc_steal(expr, res); - if (ret != LDB_SUCCESS) { + if (ret != LDB_SUCCESS || res == NULL) { goto failed; } @@ -517,7 +517,7 @@ static NTSTATUS enum_aliasmem(const DOM_SID *alias, DOM_SID **sids, size_t *num) ret = ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, attrs, &res); talloc_steal(dn, res); - if (ret == LDB_SUCCESS && res->count == 0) { + if (ret == LDB_SUCCESS && res && res->count == 0) { talloc_free(dn); return NT_STATUS_OK; }