From 255fed3b0d5b9d210d1da47dbd647dd6497cd550 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Thu, 15 Dec 2011 22:16:13 +0530 Subject: 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 Change-Id: I2f0d189a55663c7f47dddff35d4dc68fae16b755 BUG: 767591 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/797 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Reviewed-by: Jeff Darcy --- cli/src/cli-cmd-parser.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index d363e934a..17f03bb1c 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) { -- cgit