From 4f6c888c5cc32381273d563b184bcb032ee38cc9 Mon Sep 17 00:00:00 2001 From: Vijaikumar M Date: Thu, 13 Mar 2014 16:39:27 +0530 Subject: glusterd/snapshot: Validate snapshot name length while creation Change-Id: Iaee04f5209e278d83c086e32c4cafd6c571370cd Signed-off-by: Vijaikumar M Reviewed-on: http://review.gluster.org/7242 Reviewed-by: Rajesh Joseph Tested-by: Rajesh Joseph --- cli/src/cli-cmd-parser.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cli/src') diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index c5d6fa009..4357e657e 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2843,6 +2843,14 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, goto out; } + if (strlen(words[cmdi]) >= GLUSTERD_MAX_SNAP_NAME) { + cli_out ("snapshot create: failed: snapname cannot exceed " + "256 characters."); + gf_log ("cli", GF_LOG_ERROR, "Snapname too long"); + + goto out; + } + /* Snap name cannot be keyword "description" or "force" */ if (strcmp (words[cmdi], "description") == 0 || strcmp (words[cmdi], "force") == 0) { @@ -3252,6 +3260,7 @@ out : * * return value : -1 on failure * 0 on success + * 1 if user cancel the operation */ int cli_snap_delete_parse (dict_t *dict, const char **words, int wordcount, @@ -3281,7 +3290,7 @@ cli_snap_delete_parse (dict_t *dict, const char **words, int wordcount, answer = cli_cmd_get_confirmation (state, question); if (GF_ANSWER_NO == answer) { - ret = -1; + ret = 1; gf_log ("cli", GF_LOG_DEBUG, "User cancelled " "snapshot delete operation"); goto out; -- cgit