d1681e
From d463acc86f218abeba9a95b49702a5be491f3110 Mon Sep 17 00:00:00 2001
d1681e
From: Mohammed Rafi KC <rkavunga@redhat.com>
d1681e
Date: Sat, 18 Aug 2018 01:25:34 +0530
d1681e
Subject: [PATCH 352/359] snapshot:Fail snapshot creation if an empty
d1681e
 description provided
d1681e
d1681e
Snapshot description should have a valid string. Creating a
d1681e
snapshot with null value will cause reading from info file
d1681e
to fail with a null exception
d1681e
d1681e
>Change-Id: I9f84154b8e3e7ffefa5438807b3bb9b4e0d964ca
d1681e
>updates: bz#1618004
d1681e
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
d1681e
d1681e
upstream patch: https://review.gluster.org/#/c/glusterfs/+/20770/
d1681e
d1681e
Change-Id: I9f84154b8e3e7ffefa5438807b3bb9b4e0d964ca
d1681e
BUG: 1615578
d1681e
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
d1681e
Reviewed-on: https://code.engineering.redhat.com/gerrit/147517
d1681e
Tested-by: RHGS Build Bot <nigelb@redhat.com>
d1681e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
d1681e
---
d1681e
 tests/basic/uss.t                             |  1 +
d1681e
 xlators/mgmt/glusterd/src/glusterd-snapshot.c | 10 ++++++++++
d1681e
 2 files changed, 11 insertions(+)
d1681e
d1681e
diff --git a/tests/basic/uss.t b/tests/basic/uss.t
d1681e
index 6cfc030..40e556e 100644
d1681e
--- a/tests/basic/uss.t
d1681e
+++ b/tests/basic/uss.t
d1681e
@@ -52,6 +52,7 @@ TEST ln $M0/f1 $M0/dir/f3
d1681e
 TEST $CLI snapshot config activate-on-create enable
d1681e
 TEST $CLI volume set $V0 features.uss enable;
d1681e
 
d1681e
+TEST ! $CLI snapshot create snap1 $V0 no-timestamp description "";
d1681e
 TEST $CLI snapshot create snap1 $V0 no-timestamp;
d1681e
 
d1681e
 for i in {11..20} ; do echo "file" > $M0/file$i ; done
d1681e
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
d1681e
index 09e10bf..fdd5012 100644
d1681e
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
d1681e
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
d1681e
@@ -2518,6 +2518,7 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
d1681e
         int64_t                effective_max_limit = 0;
d1681e
         int                    flags             = 0;
d1681e
         uint64_t               opt_hard_max      = GLUSTERD_SNAPS_MAX_HARD_LIMIT;
d1681e
+        char                  *description       = NULL;
d1681e
 
d1681e
         this = THIS;
d1681e
         GF_ASSERT (op_errstr);
d1681e
@@ -2544,6 +2545,15 @@ glusterd_snapshot_create_prevalidate (dict_t *dict, char **op_errstr,
d1681e
                 goto out;
d1681e
         }
d1681e
 
d1681e
+        ret = dict_get_str (dict, "description", &description);
d1681e
+        if (description && !(*description)) {
d1681e
+                /* description should have a non-null value */
d1681e
+                ret = -1;
d1681e
+                snprintf (err_str, sizeof (err_str), "Snapshot cannot be "
d1681e
+                          "created with empty description");
d1681e
+                goto out;
d1681e
+        }
d1681e
+
d1681e
         ret = dict_get_int32 (dict, "flags", &flags);
d1681e
         if (ret) {
d1681e
                 gf_msg (this->name, GF_LOG_ERROR, 0,
d1681e
-- 
d1681e
1.8.3.1
d1681e