libgpo: check for talloc failures in ini file parsing routines.
authorGünther Deschner <gd@samba.org>
Thu, 12 Dec 2013 17:23:47 +0000 (18:23 +0100)
committerAndreas Schneider <asn@samba.org>
Wed, 18 Dec 2013 13:48:24 +0000 (14:48 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
libgpo/gpo_ini.c

index 1f69eecc42e200c65a752ac89684b54bdb765899..d08e0e42863974515c54d4bd3a15562b20a5cc75 100644 (file)
@@ -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;
 }