diff options
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 2b7cdd9f6..9de13e56c 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -729,42 +729,45 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount, } delimiter = strchr ((char *)words[3], ':'); - if (delimiter && delimiter != words[3] - && *(delimiter+1) == '/') { + if (!delimiter || delimiter == words[3] + || *(delimiter+1) != '/') { + cli_out ("wrong brick type: %s, use " + "<HOSTNAME>:<export-dir-abs-path>", words[3]); + ret = -1; + goto out; + } else { cli_path_strip_trailing_slashes (delimiter + 1); - ret = dict_set_str (dict, "src-brick", (char *)words[3]); - - if (ret) - goto out; + } + ret = dict_set_str (dict, "src-brick", (char *)words[3]); - if (wordcount < 5) { - ret = -1; - goto out; - } + if (ret) + goto out; - delimiter = strchr ((char *)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 (wordcount < 5) { + ret = -1; + goto out; + } + delimiter = strchr ((char *)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); + } - ret = dict_set_str (dict, "dst-brick", (char *)words[4]); - if (ret) - goto out; + ret = dict_set_str (dict, "dst-brick", (char *)words[4]); - op_index = 5; - } else { - op_index = 3; - } + if (ret) + goto out; - if (wordcount < (op_index + 1)) { + op_index = 5; + if ((wordcount < (op_index + 1)) || + (wordcount > (op_index + 1))) { ret = -1; goto out; } |