From 5886396d969a317cfd46e3da82543b0868325acc Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Mon, 26 Nov 2012 14:25:21 +0530 Subject: cli: fail vol set when value = empty string/string with all whitespaces PROBLEMS: a. 'volume set' operation accepts empty strings and strings containing all whitespaces for value. The result - subsequent attempts to start glusterd fail. b. 'volume set group' operation, when passed an empty string or string containing all spaces as value, fopens the wrong file. FIX: Made volume set parser in cli check for and invalidate value if its length is 0 after all the whitespaces have been stripped off. Change-Id: I6792ee1fe9452d8e25e1fd1eeb1b9981be3389f1 BUG: 859927 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/4246 Reviewed-by: Pranith Kumar Karampuri Tested-by: Gluster Build System Reviewed-by: Anand Avati --- cli/src/cli-cmd-parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (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 ae754b97c05..8725b79f6f7 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -832,6 +832,11 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options) if (ret == -1) goto out; + if (strlen (value) == 0) { + ret = -1; + goto out; + } + ret = cli_add_key_group (dict, key, value); if (ret == 0) *options = dict; @@ -854,6 +859,11 @@ cli_cmd_volume_set_parse (const char **words, int wordcount, dict_t **options) if (ret == -1) goto out; + if (strlen (value) == 0) { + ret = -1; + goto out; + } + if (cli_is_key_spl (key)) { ret = -1; goto out; -- cgit