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