diff options
author | Raghavendra Bhat <raghavendrabhat@gluster.com> | 2011-12-15 22:16:13 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-12-19 08:58:50 -0800 |
commit | 255fed3b0d5b9d210d1da47dbd647dd6497cd550 (patch) | |
tree | 9e29c433cc76dca8337e82088cfa2bf44ac68d48 /cli/src/cli-cmd-parser.c | |
parent | 4debbfe7f629626fd2e77a2d98f37f4e808e9f95 (diff) |
cli: validate the volume set command properly
For volume set command if after the volume name the key and the
value of the option are not given, then gracefully exit by
showing the proper usage of volume set, instead of sending the
request to glusterd, which makes glusterd crash.
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Change-Id: I2f0d189a55663c7f47dddff35d4dc68fae16b755
BUG: 767591
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/797
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index d363e934a57..17f03bb1c4e 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -667,14 +667,20 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options) if (ret) goto out; - if (!strcmp (volname, "help") && wordcount == 3 ) - ret = dict_set_str (dict, "help", volname); - - if (!strcmp (volname, "help-xml") && wordcount == 3 ) - ret = dict_set_str (dict, "help-xml", volname); - - if (ret) - goto out; + if (wordcount == 3) { + if (!strcmp (volname, "help")) { + ret = dict_set_str (dict, "help", volname); + if (ret) + goto out; + } else if (!strcmp (volname, "help-xml")) { + ret = dict_set_str (dict, "help-xml", volname); + if (ret) + goto out; + } else { + ret = -1; + goto out; + } + } for (i = 3; i < wordcount; i+=2) { |