summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijaikumar M <vmallika@redhat.com>2014-03-13 16:39:27 +0530
committerRajesh Joseph <rjoseph@redhat.com>2014-03-13 04:30:41 -0700
commit4f6c888c5cc32381273d563b184bcb032ee38cc9 (patch)
tree028beb946ae8b29730afa9e89756e5fd9492c5a0
parent2aa6db3491d58fb7e28da07fbe4d461a0a646d9b (diff)
glusterd/snapshot: Validate snapshot name length while creation
Change-Id: Iaee04f5209e278d83c086e32c4cafd6c571370cd Signed-off-by: Vijaikumar M <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/7242 Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Rajesh Joseph <rjoseph@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c11
-rw-r--r--libglusterfs/src/glusterfs.h1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h1
4 files changed, 18 insertions, 2 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index c5d6fa0..4357e65 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;
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 98f5125..2f1e12e 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -70,6 +70,7 @@
#define FNM_EXTMATCH 0
#endif
+#define GLUSTERD_MAX_SNAP_NAME 256
#define ZR_MOUNTPOINT_OPT "mountpoint"
#define ZR_ATTR_TIMEOUT_OPT "attribute-timeout"
#define ZR_ENTRY_TIMEOUT_OPT "entry-timeout"
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 900b528..c9c23bf 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -2234,6 +2234,13 @@ glusterd_handle_snapshot_create (rpcsvc_request_t *req, glusterd_op_t op,
goto out;
}
+ if (strlen(snapname) >= GLUSTERD_MAX_SNAP_NAME) {
+ snprintf (err_str, len, "Snapshot name too long");
+ gf_log (this->name, GF_LOG_ERROR, "%s", err_str);
+ ret = -1;
+ goto out;
+ }
+
uuid_ptr = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
if (!uuid_ptr) {
gf_log (this->name, GF_LOG_ERROR, "Out Of Memory");
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index b70709d..bcc376a 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -40,7 +40,6 @@
#include "store.h"
#define GLUSTERD_MAX_VOLUME_NAME 1000
-#define GLUSTERD_MAX_SNAP_NAME 128
#define GLUSTERD_TR_LOG_SIZE 50
#define GLUSTERD_NAME "glusterd"
#define GLUSTERD_SOCKET_LISTEN_BACKLOG 128