diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2017-07-26 12:46:42 +0530 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-07-31 17:29:29 +0000 |
commit | 282bff2e32903b0be1773c81ad8b9836980661cf (patch) | |
tree | 4d72d9408791781b8c3e54f51aa483d1e8e88d50 /cli/src/cli-cmd-volume.c | |
parent | 4da056a30214ad4563bdfd24ffce724b740c6b4f (diff) |
cli: error out incomplete CLI commands
cli_cmd_bricks_parse () & cli_cmd_volume_remove_brick_parse () were not
handling the the error cases where the command is incomplete with
missing brick details which could lead to glusterd crashes.
Credit : george.lian@nokia.com
>Reviewed-on: https://review.gluster.org/17870
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
>(cherry picked from commit c136024613c697fec87aaff3a070862b92c57977)
Change-Id: Ia6303457a2aa279465aa75d4e1cfcc948893d5de
BUG: 1475641
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: https://review.gluster.org/17892
Smoke: Gluster Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
-rw-r--r-- | cli/src/cli-cmd-volume.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 81b273e2777..a83e281a23c 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1980,6 +1980,7 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, call_frame_t *frame = NULL; dict_t *options = NULL; gf_answer_t answer = GF_ANSWER_NO; + int brick_count = 0; int sent = 0; int parse_error = 0; int need_question = 0; @@ -1998,13 +1999,19 @@ cli_cmd_volume_remove_brick_cbk (struct cli_state *state, goto out; ret = cli_cmd_volume_remove_brick_parse (words, wordcount, &options, - &need_question); + &need_question, &brick_count); if (ret) { cli_usage_out (word->pattern); parse_error = 1; goto out; } - + if (!brick_count) { + cli_err ("No bricks specified"); + cli_usage_out (word->pattern); + parse_error = 1; + ret = -1; + goto out; + } ret = dict_get_str (options, "volname", &volname); if (ret || !volname) { gf_log ("cli", GF_LOG_ERROR, "Failed to fetch volname"); |