summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-06-20 14:13:45 +0200
committerAnand Avati <avati@redhat.com>2012-07-11 19:18:01 -0700
commit7f2788675ba99193b7f18b3b9efbbbe3b5d0b2e5 (patch)
tree892d0c1d1a8f5adde4eb7e73ad7773ae02671003
parenta8ce48126dc57726f820e8815cff8b24911ca076 (diff)
cli: cli_cmd_get_confirmation: don't reference answer[-1] for NUL input
Change-Id: I83baa54fc5392e92a6a451c549d356ff1ffc92cb BUG: 789278 Signed-off-by: Jim Meyering <meyering@redhat.com> Reviewed-on: http://review.gluster.com/3606 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--cli/src/cli-cmd-volume.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index c0faaa07b56..19b821bd85d 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -545,7 +545,7 @@ cli_cmd_get_confirmation (struct cli_state *state, const char *question)
{
char answer[5] = {'\0', };
char flush = '\0';
- int len = 0;
+ size_t len;
if (state->mode & GLUSTER_MODE_SCRIPT)
return GF_ANSWER_YES;
@@ -559,7 +559,7 @@ cli_cmd_get_confirmation (struct cli_state *state, const char *question)
len = strlen (answer);
- if (answer [len - 1] == '\n'){
+ if (len && answer [len - 1] == '\n'){
answer [--len] = '\0';
} else {
do{