summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorPranith K <pranithk@gluster.com>2010-11-16 01:26:00 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-11-15 23:46:03 -0800
commiteb13791c229b011b41e63099ce097a4271ae0451 (patch)
tree79969c7716375b519b5b81649435eb7bccaa3492 /cli
parentbc3cad79cd0cf48318e723fd3377af979673374e (diff)
cli: fix memory corruption in create volume and add-brick
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> 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
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c19
1 files changed, 17 insertions, 2 deletions
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;