summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorMohammed Rafi KC <rkavunga@redhat.com>2018-08-16 17:04:22 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-08-20 02:55:43 +0000
commit4814140a539f4685bf439b456381751ee84be8fa (patch)
tree0ff940fb5d6f3a8e1804e7184f3b83d9a296e5b1 /xlators
parent8549ba1a3de8bba7c80ea24121fb095cd756c64e (diff)
snapshot/handshake: store description after strdup
problem: During a handshake, when we import a friend data snap description variable was just referenced to dictionary value. Solution: snap description should have a separate memory allocated through gf_strdup Change-Id: I94da0c57919e1228919231d1563a001362b100b8 fixes: bz#1618004 Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
index d5cb5ea778b..2e1ce7dd48c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
@@ -761,7 +761,7 @@ glusterd_add_snap_to_dict (glusterd_snap_t *snap, dict_t *peer_data,
}
if (snap->description) {
- snprintf (buf, sizeof(buf), "%s.snapid", prefix);
+ snprintf (buf, sizeof(buf), "%s.description", prefix);
ret = dict_set_dynstr_with_alloc (peer_data, buf,
snap->description);
if (ret) {
@@ -1544,6 +1544,7 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
{
char buf[64] = "";
char prefix[32] = "";
+ char *description = NULL;
dict_t *dict = NULL;
glusterd_snap_t *snap = NULL;
glusterd_volinfo_t *snap_vol = NULL;
@@ -1583,8 +1584,18 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count,
gf_strncpy (snap->snapname, peer_snap_name, sizeof(snap->snapname));
gf_uuid_parse (peer_snap_id, snap->snap_id);
- snprintf (buf, sizeof(buf), "%s.snapid", prefix);
- ret = dict_get_str (peer_data, buf, &snap->description);
+ snprintf (buf, sizeof(buf), "%s.description", prefix);
+ ret = dict_get_str (peer_data, buf, &description);
+ if (ret == 0 && description) {
+ snap->description = gf_strdup (description);
+ if (snap->description == NULL) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SNAP_CREATION_FAIL,
+ "Saving the Snapshot Description Failed");
+ ret = -1;
+ goto out;
+ }
+ }
snprintf (buf, sizeof(buf), "%s.time_stamp", prefix);
ret = dict_get_int64 (peer_data, buf, &snap->time_stamp);