summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2010-09-06 08:27:20 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-09-06 09:38:11 -0700
commit6307567a26ecf296b5f806050867beb3c7cccd4f (patch)
treea350150521849f160665cd46b29a0496b1014490 /cli
parent8432a5bf65174144c58d3322066abeb85c9f3541 (diff)
cli: check for argument presence before accessing
Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1543 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1543
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-parser.c18
1 files changed, 14 insertions, 4 deletions
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], ':');