From 5ad8b6779db0ffacf876e254621ee7111f7f82b0 Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Sat, 18 Aug 2018 01:25:34 +0530 Subject: snapshot:Fail snapshot creation if an empty description provided Snapshot description should have a valid string. Creating a snapshot with null value will cause reading from info file to fail with a null exception Change-Id: I9f84154b8e3e7ffefa5438807b3bb9b4e0d964ca updates: bz#1618004 Signed-off-by: Mohammed Rafi KC --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'xlators/mgmt') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 99ec7d3afef..7adc3c87f77 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -2472,6 +2472,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, int64_t effective_max_limit = 0; int flags = 0; uint64_t opt_hard_max = GLUSTERD_SNAPS_MAX_HARD_LIMIT; + char *description = NULL; this = THIS; GF_ASSERT (op_errstr); @@ -2498,6 +2499,15 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr, goto out; } + ret = dict_get_str (dict, "description", &description); + if (description && !(*description)) { + /* description should have a non-null value */ + ret = -1; + snprintf (err_str, sizeof (err_str), "Snapshot cannot be " + "created with empty description"); + goto out; + } + ret = dict_get_int32 (dict, "flags", &flags); if (ret) { gf_msg (this->name, GF_LOG_ERROR, 0, -- cgit