Skip to content

Commit

Permalink
libgpo: check for talloc failures in ini file parsing routines.
Browse files Browse the repository at this point in the history
Guenther

Signed-off-by: Günther Deschner <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
  • Loading branch information
gd authored and cryptomilk committed Dec 18, 2013
1 parent 078c868 commit 785c3c1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libgpo/gpo_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down

0 comments on commit 785c3c1

Please sign in to comment.