From 37f6b1a70e5ca702e2081283755c4b9dd9a4b799 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Thu, 8 Jan 2009 11:42:33 -0500 Subject: Fix a bug in confdb_get_string where attempting to return a default string of NULL would erroneously report ENOMEM. --- server/confdb/confdb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/confdb/confdb.c b/server/confdb/confdb.c index 7d11fae7..9a0e365e 100644 --- a/server/confdb/confdb.c +++ b/server/confdb/confdb.c @@ -306,10 +306,20 @@ int confdb_get_string(struct confdb_ctx *cdb, TALLOC_CTX *ctx, } restr = talloc_steal(ctx, values[0]); } else { + /* Did not return a value, so use the default */ + + if (defstr == NULL) { /* No default given */ + *result = NULL; + talloc_free(values); + return EOK; + } + + /* Copy the default string */ restr = talloc_strdup(ctx, defstr); } if (!restr) { talloc_free(values); + DEBUG(0, ("Out of memory\n")); return ENOMEM; } @@ -540,7 +550,7 @@ int confdb_get_domain_basedn(struct confdb_ctx *cdb, section = talloc_asprintf(mem_ctx, "config/domains/%s", domain); ret = confdb_get_string(cdb, mem_ctx, section, "basedn", "cn=local", basedn); - + talloc_free(section); return ret; } -- cgit