From 8d92fabe6a29143a70b26182e63dddfb80c14f98 Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Wed, 3 Oct 2012 12:22:50 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/4025 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Anand Avati --- cli/src/cli-rpc-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cli') 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'; -- cgit