summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Reichl <preichl@redhat.com>2014-06-19 12:23:26 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-06-19 14:09:44 +0200
commita436e75aae489f35dedd1186fad2f07d23564102 (patch)
tree6ef76044b2c9931d5d57d881b9535d8b2dd6fe0c
parent4b9a43bda65f8950e92bc86474883ff27caa27d6 (diff)
downloadsssd-a436e75aae489f35dedd1186fad2f07d23564102.tar.gz
sssd-a436e75aae489f35dedd1186fad2f07d23564102.tar.xz
sssd-a436e75aae489f35dedd1186fad2f07d23564102.zip
SYSDB: sysdb_search_custom fix memory leak
Add temporally talloc context to allocate basedn on. Reviewed-by: Stephen Gallagher <sgallagh@redhat.com> (cherry picked from commit a4caef931a245fb3c44b70ea65a58bd0c1ff8dc4)
-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 3a41f514a..379d0f8eb 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -2235,26 +2235,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(sysdb, mem_ctx, domain, subtree_name);
+ basedn = sysdb_custom_subtree_dn(sysdb, 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, sysdb, basedn,
LDB_SCOPE_SUBTREE, filter, attrs,
msgs_count, msgs);
+done:
+ talloc_free(tmp_ctx);
return ret;
}