From 785c3c12a9fc6bebdce518bbd1de4f5fcb5c1670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Thu, 12 Dec 2013 18:23:47 +0100 Subject: libgpo: check for talloc failures in ini file parsing routines. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Guenther Signed-off-by: Günther Deschner Reviewed-by: Andreas Schneider --- libgpo/gpo_ini.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libgpo') 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; } -- cgit v1.2.1