diff options
-rw-r--r-- | src/db/sysdb_ops.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 500860f48..915ef1ad9 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -2140,26 +2140,38 @@ int sysdb_search_custom(TALLOC_CTX *mem_ctx, size_t *msgs_count, struct ldb_message ***msgs) { - struct ldb_dn *basedn; + TALLOC_CTX *tmp_ctx; + struct ldb_dn *basedn = NULL; int ret; + tmp_ctx = talloc_new(NULL); + if (tmp_ctx == NULL) { + ret = ENOMEM; + goto done; + } + if (filter == NULL || subtree_name == NULL) { - return EINVAL; + ret = EINVAL; + goto done; } - basedn = sysdb_custom_subtree_dn(mem_ctx, domain, subtree_name); + basedn = sysdb_custom_subtree_dn(tmp_ctx, domain, subtree_name); if (basedn == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_custom_subtree_dn failed.\n"); - return ENOMEM; + ret = ENOMEM; + goto done; } if (!ldb_dn_validate(basedn)) { DEBUG(SSSDBG_CRIT_FAILURE, "Failed to create DN.\n"); - return EINVAL; + ret = EINVAL; + goto done; } ret = sysdb_search_entry(mem_ctx, domain->sysdb, basedn, LDB_SCOPE_SUBTREE, filter, attrs, msgs_count, msgs); +done: + talloc_free(tmp_ctx); return ret; } |