From d06e6bac4b5aa6d0fbf1660b92c4100de8f79e68 Mon Sep 17 00:00:00 2001 From: vmallika Date: Wed, 1 Apr 2015 16:56:00 +0530 Subject: quota/cli: validate quota hard-limit option Quota hard-limit is supported only upto: 9223372036854775807 (int 64) In CLI, it is allowed to set the value upto 16384PB (unsigned int 64), this is not a valid value as the xattrop for quota accounting and the quota enforcer operates on a signed int64 limit value. This patches fixes the problem in CLI and allows user to set the hard-limit value only from range 0 - 9223372036854775807 Change-Id: Ifce6e509e1832ef21d3278bacfa5bd71040c8cba BUG: 1206432 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/10022 Tested-by: Gluster Build System Reviewed-by: Kaushal M Reviewed-by: Vijay Bellur --- cli/src/cli-cmd-parser.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'cli/src/cli-cmd-parser.c') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index da60cde66d9..a8e09a46631 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -906,7 +906,7 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) int ret = -1; int i = -1; char key[20] = {0, }; - uint64_t value = 0; + int64_t value = 0; gf_quota_type type = GF_QUOTA_OPTION_TYPE_NONE; char *opwords[] = { "enable", "disable", "limit-usage", "remove", "list", "alert-time", @@ -1004,11 +1004,12 @@ cli_cmd_quota_parse (const char **words, int wordcount, dict_t **options) } if (type == GF_QUOTA_OPTION_TYPE_LIMIT_USAGE) { - ret = gf_string2bytesize_uint64 (words[5], &value); - if (ret != 0) { - if (errno == ERANGE) - cli_err ("Value too large: %s", - words[5]); + ret = gf_string2bytesize_int64 (words[5], &value); + if (ret != 0 || value < 0) { + if (errno == ERANGE || value < 0) + cli_err ("Value out of range " + "(0 - %"PRId64 "): %s", + INT64_MAX, words[5]); else cli_err ("Please enter a correct " "value"); -- cgit