summaryrefslogtreecommitdiffstats
path: root/src/responder/secrets
diff options
context:
space:
mode:
authorFabiano FidĂȘncio <fidencio@redhat.com>2016-09-26 01:15:56 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-10-03 15:32:29 +0200
commitd806427f200dc1ffd44d37724eb40125af5cc8c2 (patch)
tree2a06ebc85e1f420a32ded01ad341c461a15a19c7 /src/responder/secrets
parentf35f4e4c8bd5b834504c0554552d78db3624706a (diff)
downloadsssd-d806427f200dc1ffd44d37724eb40125af5cc8c2.tar.gz
sssd-d806427f200dc1ffd44d37724eb40125af5cc8c2.tar.xz
sssd-d806427f200dc1ffd44d37724eb40125af5cc8c2.zip
SECRETS: Use a tmp_context on local_db_check_containers()
Otherwise the struct ldb_dn will be hanging on the mem_ctx till it gets freed. Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/responder/secrets')
-rw-r--r--src/responder/secrets/local.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/responder/secrets/local.c b/src/responder/secrets/local.c
index 0ce0526cf..484e40643 100644
--- a/src/responder/secrets/local.c
+++ b/src/responder/secrets/local.c
@@ -286,14 +286,21 @@ static int local_db_check_containers(TALLOC_CTX *mem_ctx,
struct local_context *lctx,
struct ldb_dn *leaf_dn)
{
+ TALLOC_CTX *tmp_ctx;
static const char *attrs[] = { NULL};
struct ldb_result *res = NULL;
struct ldb_dn *dn;
int num;
int ret;
- dn = ldb_dn_copy(mem_ctx, leaf_dn);
- if (!dn) return ENOMEM;
+ tmp_ctx = talloc_new(mem_ctx);
+ if (!tmp_ctx) return ENOMEM;
+
+ dn = ldb_dn_copy(tmp_ctx, leaf_dn);
+ if (!dn) {
+ ret = ENOMEM;
+ goto done;
+ }
/* We need to exclude the leaf as that will be the new child entry,
* We also do not care for the synthetic containers that constitute the
@@ -306,14 +313,23 @@ static int local_db_check_containers(TALLOC_CTX *mem_ctx,
if (!ldb_dn_remove_child_components(dn, 1)) return EFAULT;
/* and check the parent container exists */
- ret = ldb_search(lctx->ldb, mem_ctx, &res, dn, LDB_SCOPE_BASE,
+ ret = ldb_search(lctx->ldb, tmp_ctx, &res, dn, LDB_SCOPE_BASE,
attrs, LOCAL_CONTAINER_FILTER);
- if (ret != LDB_SUCCESS) return ENOENT;
- if (res->count != 1) return ENOENT;
- talloc_free(res);
+ if (ret != LDB_SUCCESS) {
+ ret = ENOENT;
+ goto done;
+ }
+ if (res->count != 1) {
+ ret = ENOENT;
+ goto done;
+ }
}
- return EOK;
+ ret = EOK;
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
}
static int local_db_put_simple(TALLOC_CTX *mem_ctx,