diff options
Diffstat (limited to 'source4/param/share_ldb.c')
-rw-r--r-- | source4/param/share_ldb.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c index 0e27376e96d..0257cd1b937 100644 --- a/source4/param/share_ldb.c +++ b/source4/param/share_ldb.c @@ -58,13 +58,13 @@ static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, return NT_STATUS_OK; } -static const char *sldb_string_option(struct share_config *scfg, const char *opt_name, const char *defval) +static char *sldb_string_option(TALLOC_CTX *mem_ctx, struct share_config *scfg, const char *opt_name, const char *defval) { struct ldb_message *msg; struct ldb_message_element *el; const char *colon; - if (scfg == NULL) return defval; + if (scfg == NULL) return talloc_strdup(mem_ctx, defval); msg = talloc_get_type(scfg->opaque, struct ldb_message); @@ -85,22 +85,24 @@ static const char *sldb_string_option(struct share_config *scfg, const char *opt } if (el == NULL) { - return defval; + return talloc_strdup(mem_ctx, defval); } - return (const char *)(el->values[0].data); + return (char *)(el->values[0].data); } static int sldb_int_option(struct share_config *scfg, const char *opt_name, int defval) { - const char *val; + char *val; int ret; - val = sldb_string_option(scfg, opt_name, NULL); + val = sldb_string_option(scfg, scfg, opt_name, NULL); if (val == NULL) return defval; errno = 0; ret = (int)strtol(val, NULL, 10); + TALLOC_FREE(val); + if (errno) return -1; return ret; @@ -108,13 +110,17 @@ static int sldb_int_option(struct share_config *scfg, const char *opt_name, int static bool sldb_bool_option(struct share_config *scfg, const char *opt_name, bool defval) { - const char *val; + char *val; - val = sldb_string_option(scfg, opt_name, NULL); + val = sldb_string_option(scfg, scfg, opt_name, NULL); if (val == NULL) return defval; - if (strcasecmp(val, "true") == 0) return true; + if (strcasecmp(val, "true") == 0) { + TALLOC_FREE(val); + return true; + } + TALLOC_FREE(val); return false; } |