diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2012-10-03 12:22:50 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-10-03 14:18:13 -0700 |
commit | 8d92fabe6a29143a70b26182e63dddfb80c14f98 (patch) | |
tree | 7c92b486f3547f2cf20c3be014938f751f2d5acd /cli/src | |
parent | 557602e7637a7ef702db2b60f9cf10ecbe2837f3 (diff) |
cli: fixed cli crash during volume set operation
PROBLEM:
The cli crashes in the following case:
gluster> volume set v3 auth.allow "write-behind"
CAUSE:
The second strncat operation in the last iteration of the for loop,
in cli_to_glusterd writes off the end of the space malloc'd for "cmd",
leading to memory corruption.
FIX:
Made the last strncat operation conditional so that in the last
iteration, strncat is avoided.
Change-Id: I8f836c684f33a6328e384ab8e677b8e32bcb4e55
BUG: 862526
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/4025
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 104bca1ec75..ce06ce2f83a 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -6005,7 +6005,8 @@ cli_to_glusterd (gf_cli_req *req, call_frame_t *frame, for (i = 0; words[i]; i++) { strncat (cmd, words[i], strlen (words[i])); - strncat (cmd, " ", strlen (" ")); + if (words[i+1] != NULL) + strncat (cmd, " ", strlen (" ")); } cmd [len - 1] = '\0'; |