summaryrefslogtreecommitdiff
path: root/src/confdb
diff options
context:
space:
mode:
Diffstat (limited to 'src/confdb')
-rw-r--r--src/confdb/confdb.c45
-rw-r--r--src/confdb/confdb.h4
2 files changed, 35 insertions, 14 deletions
diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
index 57023f29..04f02b5c 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;
diff --git a/src/confdb/confdb.h b/src/confdb/confdb.h
index 819e8ff3..18484f02 100644
--- a/src/confdb/confdb.h
+++ b/src/confdb/confdb.h
@@ -343,7 +343,7 @@ int confdb_get_string(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
* @return ERANGE - The value stored in the ConfDB was outside the range
* [INT_MIN..INT_MAX]
*/
-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);
@@ -372,7 +372,7 @@ int confdb_get_int(struct confdb_ctx *cdb, TALLOC_CTX *ctx,
* single-valued, or the value was not a boolean.
* @return EIO - An I/O error occurred while communicating with the ConfDB
*/
-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);