diff options
author | Amar Tumballi <amar@gluster.com> | 2010-09-23 00:45:53 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-23 00:15:22 -0700 |
commit | 7f645c3ac3678bab9b74c62b33951450841af967 (patch) | |
tree | bd1648dae4afd02508a819b1c57a976f5e503a6e /cli | |
parent | 2b0299da40ec4d35106d1caaadf936387a54fcce (diff) |
gluster cli: handle case of no brick given in log locate/rotatev3.1.0qa29
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1679 (gluster volume log locate/rotate segfault)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1679
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 9de13e56ce7..875ead0642e 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -897,20 +897,22 @@ cli_cmd_log_locate_parse (const char **words, int wordcount, dict_t **options) if (ret) goto out; - delimiter = strchr (words[4], ':'); - if (!delimiter || delimiter == words[4] - || *(delimiter+1) != '/') { - cli_out ("wrong brick type: %s, use <HOSTNAME>:" - "<export-dir-abs-path>", words[4]); - ret = -1; - goto out; - } else { - cli_path_strip_trailing_slashes (delimiter + 1); + if (words[4]) { + delimiter = strchr (words[4], ':'); + if (!delimiter || delimiter == words[4] + || *(delimiter+1) != '/') { + cli_out ("wrong brick type: %s, use <HOSTNAME>:" + "<export-dir-abs-path>", words[4]); + ret = -1; + goto out; + } else { + cli_path_strip_trailing_slashes (delimiter + 1); + } + str = (char *)words[4]; + ret = dict_set_str (dict, "brick", str); + if (ret) + goto out; } - str = (char *)words[4]; - ret = dict_set_str (dict, "brick", str); - if (ret) - goto out; *options = dict; @@ -948,20 +950,22 @@ cli_cmd_log_rotate_parse (const char **words, int wordcount, dict_t **options) if (ret) goto out; - delimiter = strchr (words[4], ':'); - if (!delimiter || delimiter == words[4] - || *(delimiter+1) != '/') { - cli_out ("wrong brick type: %s, use <HOSTNAME>:" - "<export-dir-abs-path>", words[4]); - ret = -1; - goto out; - } else { - cli_path_strip_trailing_slashes (delimiter + 1); + if (words[4]) { + delimiter = strchr (words[4], ':'); + if (!delimiter || delimiter == words[4] + || *(delimiter+1) != '/') { + cli_out ("wrong brick type: %s, use <HOSTNAME>:" + "<export-dir-abs-path>", words[4]); + ret = -1; + goto out; + } else { + cli_path_strip_trailing_slashes (delimiter + 1); + } + str = (char *)words[4]; + ret = dict_set_str (dict, "brick", str); + if (ret) + goto out; } - str = (char *)words[4]; - ret = dict_set_str (dict, "brick", str); - if (ret) - goto out; *options = dict; |