From d9e5e97c90b31b84c3abf6e7ce92176afa950f61 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Fri, 8 Jul 2011 12:23:34 -0400 Subject: Allow NULL memctx in sysdb_custom_subtree_dn ldb_dn_new_fmt() has a bug and cannot take a NULL memory context --- src/db/sysdb.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/db/sysdb.c') 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; } -- cgit