summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2011-07-08 12:23:34 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-07-08 15:43:59 -0400
commitd9e5e97c90b31b84c3abf6e7ce92176afa950f61 (patch)
treed3dda001f74d383cb6be000fb074e06e4675baaa
parent37e7e93f1996cf50677cf59fd8af6938dd5d85b2 (diff)
downloadsssd-d9e5e97c90b31b84c3abf6e7ce92176afa950f61.tar.gz
sssd-d9e5e97c90b31b84c3abf6e7ce92176afa950f61.tar.bz2
sssd-d9e5e97c90b31b84c3abf6e7ce92176afa950f61.zip
Allow NULL memctx in sysdb_custom_subtree_dn
ldb_dn_new_fmt() has a bug and cannot take a NULL memory context
-rw-r--r--src/db/sysdb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index ffe9ff77..8165e923 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -96,15 +96,23 @@ struct ldb_dn *sysdb_custom_subtree_dn(struct sysdb_ctx *ctx, void *memctx,
errno_t ret;
char *clean_subtree;
struct ldb_dn *dn = NULL;
+ TALLOC_CTX *tmp_ctx;
+
+ tmp_ctx = talloc_new(memctx);
+ if (!tmp_ctx) return NULL;
- ret = sysdb_dn_sanitize(NULL, subtree_name, &clean_subtree);
+ ret = sysdb_dn_sanitize(tmp_ctx, subtree_name, &clean_subtree);
if (ret != EOK) {
+ talloc_free(tmp_ctx);
return NULL;
}
- dn = ldb_dn_new_fmt(memctx, ctx->ldb, SYSDB_TMPL_CUSTOM_SUBTREE,
+ dn = ldb_dn_new_fmt(tmp_ctx, ctx->ldb, SYSDB_TMPL_CUSTOM_SUBTREE,
clean_subtree, domain);
- talloc_free(clean_subtree);
+ if (dn) {
+ talloc_steal(memctx, dn);
+ }
+ talloc_free(tmp_ctx);
return dn;
}