summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorPavel Reichl <preichl@redhat.com>2014-06-19 12:23:26 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-06-20 10:37:40 +0200
commita4caef931a245fb3c44b70ea65a58bd0c1ff8dc4 (patch)
tree7f4c919324e8366623cf3deacc7d9ff8d8f7f125 /src/db
parent09579ae252c181c7884defc0612c36108f6cf509 (diff)
downloadsssd-a4caef931a245fb3c44b70ea65a58bd0c1ff8dc4.tar.gz
sssd-a4caef931a245fb3c44b70ea65a58bd0c1ff8dc4.tar.xz
sssd-a4caef931a245fb3c44b70ea65a58bd0c1ff8dc4.zip
SYSDB: sysdb_search_custom fix memory leak
Add temporally talloc context to allocate basedn on. Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb_ops.c22
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;
}