From 6307567a26ecf296b5f806050867beb3c7cccd4f Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 6 Sep 2010 08:27:20 +0000 Subject: cli: check for argument presence before accessing Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1543 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1543 --- cli/src/cli-cmd-parser.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index ab06cb009..41c1cc098 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -145,13 +145,23 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options if (ret) goto out; - if (type) + if (type) index = 5; else index = 3; + if (wordcount < (index + 1)) { + ret = -1; + goto out; + } + if (strcasecmp(words[index], "transport") == 0) { brick_index = index+2; + if (wordcount < (index + 2)) { + ret = -1; + goto out; + } + if ((strcasecmp (words[index+1], "tcp") == 0)) { trans_type = gf_strdup ("tcp"); } else if ((strcasecmp (words[index+1], "rdma") == 0)) { @@ -161,15 +171,15 @@ cli_cmd_volume_create_parse (const char **words, int wordcount, dict_t **options " protocol specified"); ret = -1; goto out; - } - } else { + } + } else { trans_type = gf_strdup ("tcp"); } ret = dict_set_str (dict, "transport", trans_type); if (ret) goto out; - + strcpy (brick_list, " "); while (brick_index < wordcount) { delimiter = strchr (words[brick_index], ':'); -- cgit