From 0d9a38bb576beac24d0694633a79cff7e8c11a9f Mon Sep 17 00:00:00 2001 From: Varun Shastry Date: Mon, 29 Oct 2012 16:21:24 +0530 Subject: features/quota: Failure of quota commands if the dir-name contains ':' in it PROBLEM: The first colon in the limit string is used to separate the path and the limit-value. The ':' in the path was the source of problem. FIX: Search for the last colon and separate based on the same. Added regression test. TEST: Create and set quota on directories with names containing ':' in start, middle and end. Change-Id: I363c8ad4cbfd02c23fc73974bef9aa8bc362d29c BUG: 848251 Signed-off-by: Varun Shastry Reviewed-on: http://review.gluster.org/4137 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- cli/src/cli-rpc-ops.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 256f3299f9b..2e0c58402bf 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -1998,7 +1998,7 @@ gf_cli_print_limit_list (char *volname, char *limit_list, { int64_t size = 0; int64_t limit_value = 0; - int32_t i, j, k; + int32_t i, j; int32_t len = 0, ret = -1; char *size_str = NULL; char path [PATH_MAX] = {0, }; @@ -2006,6 +2006,7 @@ gf_cli_print_limit_list (char *volname, char *limit_list, char value [1024] = {0, }; char mountdir [] = "/tmp/mntXXXXXX"; char abspath [PATH_MAX] = {0, }; + char *colon_ptr = NULL; runner_t runner = {0,}; GF_VALIDATE_OR_GOTO ("cli", volname, out); @@ -2053,19 +2054,16 @@ gf_cli_print_limit_list (char *volname, char *limit_list, "-----------------------"); while (i < len) { j = 0; - k = 0; - - while (limit_list [i] != ':') { - path [k++] = limit_list [i++]; - } - path [k] = '\0'; - - i++; //skip ':' while (limit_list [i] != ',' && limit_list [i] != '\0') { - value [j++] = limit_list[i++]; + path [j++] = limit_list[i++]; } - value [j] = '\0'; + path [j] = '\0'; + //here path[] contains both path and limit value + + colon_ptr = strrchr (path, ':'); + *colon_ptr = '\0'; + strcpy (value, ++colon_ptr); snprintf (abspath, sizeof (abspath), "%s/%s", mountdir, path); -- cgit