summaryrefslogtreecommitdiffstats
path: root/libgpo
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2013-12-12 18:23:47 +0100
committerAndreas Schneider <asn@samba.org>2013-12-18 14:48:24 +0100
commit785c3c12a9fc6bebdce518bbd1de4f5fcb5c1670 (patch)
tree2059a174f8aac8dc477648751250959a4de70a08 /libgpo
parent078c86810f6d3a9c800e00e818531c1df164f763 (diff)
downloadsamba-785c3c12a9fc6bebdce518bbd1de4f5fcb5c1670.tar.gz
samba-785c3c12a9fc6bebdce518bbd1de4f5fcb5c1670.tar.xz
samba-785c3c12a9fc6bebdce518bbd1de4f5fcb5c1670.zip
libgpo: check for talloc failures in ini file parsing routines.
Guenther Signed-off-by: Günther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'libgpo')
-rw-r--r--libgpo/gpo_ini.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libgpo/gpo_ini.c b/libgpo/gpo_ini.c
index 1f69eecc42e..d08e0e42863 100644
--- a/libgpo/gpo_ini.c
+++ b/libgpo/gpo_ini.c
@@ -32,6 +32,9 @@ static bool change_section(const char *section, void *ctx_ptr)
talloc_free(ctx->current_section);
}
ctx->current_section = talloc_strdup(ctx, section);
+ if (!ctx->current_section) {
+ return false;
+ }
return true;
}
@@ -41,10 +44,25 @@ static bool change_section(const char *section, void *ctx_ptr)
static bool store_keyval_pair(const char *key, const char *value, void *ctx_ptr)
{
struct gp_inifile_context *ctx = (struct gp_inifile_context *) ctx_ptr;
+
ctx->data = talloc_realloc(ctx, ctx->data, struct keyval_pair *, ctx->keyval_count+1);
+ if (!ctx->data) {
+ return false;
+ }
+
ctx->data[ctx->keyval_count] = talloc_zero(ctx, struct keyval_pair);
+ if (!ctx->data[ctx->keyval_count]) {
+ return false;
+ }
+
ctx->data[ctx->keyval_count]->key = talloc_asprintf(ctx, "%s:%s", ctx->current_section, key);
ctx->data[ctx->keyval_count]->val = talloc_strdup(ctx, value);
+
+ if (!ctx->data[ctx->keyval_count]->key ||
+ !ctx->data[ctx->keyval_count]->val) {
+ return false;
+ }
+
ctx->keyval_count++;
return true;
}