summaryrefslogtreecommitdiffstats
path: root/src/confdb/confdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/confdb/confdb.c')
-rw-r--r--src/confdb/confdb.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
index 57023f299..04f02b5cc 100644
--- a/src/confdb/confdb.c
+++ b/src/confdb/confdb.c
@@ -337,15 +337,22 @@ failed:
return ret;
}
-int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+int confdb_get_int(struct confdb_ctx *cdb,
const char *section, const char *attribute,
int defval, int *result)
{
char **values = NULL;
long val;
int ret;
+ TALLOC_CTX *tmp_ctx;
- ret = confdb_get_param(cdb, ctx, section, attribute, &values);
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ ret = ENOMEM;
+ goto failed;
+ }
+
+ ret = confdb_get_param(cdb, tmp_ctx, section, attribute, &values);
if (ret != EOK) {
goto failed;
}
@@ -373,27 +380,34 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
val = defval;
}
- talloc_free(values);
+ talloc_free(tmp_ctx);
*result = (int)val;
return EOK;
failed:
- talloc_free(values);
+ talloc_free(tmp_ctx);
DEBUG(1, ("Failed to read [%s] from [%s], error [%d] (%s)\n",
attribute, section, ret, strerror(ret)));
return ret;
}
-long confdb_get_long(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+long confdb_get_long(struct confdb_ctx *cdb,
const char *section, const char *attribute,
long defval, long *result)
{
char **values = NULL;
long val;
int ret;
+ TALLOC_CTX *tmp_ctx;
- ret = confdb_get_param(cdb, ctx, section, attribute, &values);
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ ret = ENOMEM;
+ goto failed;
+ }
+
+ ret = confdb_get_param(cdb, tmp_ctx, section, attribute, &values);
if (ret != EOK) {
goto failed;
}
@@ -416,27 +430,34 @@ long confdb_get_long(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
val = defval;
}
- talloc_free(values);
+ talloc_free(tmp_ctx);
*result = val;
return EOK;
failed:
- talloc_free(values);
+ talloc_free(tmp_ctx);
DEBUG(1, ("Failed to read [%s] from [%s], error [%d] (%s)\n",
attribute, section, ret, strerror(ret)));
return ret;
}
-int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
+int confdb_get_bool(struct confdb_ctx *cdb,
const char *section, const char *attribute,
bool defval, bool *result)
{
char **values = NULL;
bool val;
int ret;
+ TALLOC_CTX *tmp_ctx;
- ret = confdb_get_param(cdb, ctx, section, attribute, &values);
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ ret = ENOMEM;
+ goto failed;
+ }
+
+ ret = confdb_get_param(cdb, tmp_ctx, section, attribute, &values);
if (ret != EOK) {
goto failed;
}
@@ -465,13 +486,13 @@ int confdb_get_bool(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
val = defval;
}
- talloc_free(values);
+ talloc_free(tmp_ctx);
*result = val;
return EOK;
failed:
- talloc_free(values);
+ talloc_free(tmp_ctx);
DEBUG(1, ("Failed to read [%s] from [%s], error [%d] (%s)\n",
attribute, section, ret, strerror(ret)));
return ret;