From eb13791c229b011b41e63099ce097a4271ae0451 Mon Sep 17 00:00:00 2001 From: Pranith K Date: Tue, 16 Nov 2010 01:26:00 +0000 Subject: cli: fix memory corruption in create volume and add-brick Signed-off-by: Pranith Kumar K Signed-off-by: Anand V. Avati BUG: 2113 (cli: memory corruption in add-brick and create volume parsing functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2113 --- cli/src/cli-cmd-parser.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index ecf22931efe..0b9f38bdb0b 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -58,6 +58,7 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options char *trans_type = NULL; int32_t index = 0; char *free_list_ptr = NULL; + char *bricks = NULL; GF_ASSERT (words); GF_ASSERT (options); @@ -272,7 +273,13 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options goto out; } - ret = dict_set_str (dict, "bricks", brick_list); + bricks = gf_strdup (brick_list); + if (!bricks) { + ret = -1; + goto out; + } + + ret = dict_set_dynstr (dict, "bricks", bricks); if (ret) goto out; @@ -442,6 +449,7 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, char *tmp = NULL; char *freeptr = NULL; char *free_list_ptr = NULL; + char *bricks = NULL; GF_ASSERT (words); GF_ASSERT (options); @@ -545,7 +553,14 @@ cli_cmd_volume_add_brick_parse (const char **words, int wordcount, if (free_list_ptr) free (free_list_ptr); } - ret = dict_set_str (dict, "bricks", brick_list); + + bricks = gf_strdup (brick_list); + if (!bricks) { + ret = -1; + goto out; + } + + ret = dict_set_dynstr (dict, "bricks", bricks); if (ret) goto out; -- cgit