summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 671271aea..7711bd61a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -2090,6 +2090,7 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
int ret = -1;
char *volname = NULL;
char *snapname = NULL;
+ char *buf = NULL;
glusterd_conf_t *conf = NULL;
xlator_t *this = NULL;
int32_t cmd = -1;
@@ -2127,14 +2128,22 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
list_for_each_entry (snap, &conf->snapshots, snap_list)
{
snprintf (key, sizeof (key), "snapname%d", i);
- ret = dict_set_str (dict, key, snap->snapname);
+ buf = gf_strdup (snap->snapname);
+ if (!buf) {
+ ret = -1;
+ goto out;
+ }
+ ret = dict_set_dynstr (dict, key, buf);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Could not save snapname (%s) "
"in the dictionary",
snap->snapname);
+ GF_FREE (buf);
goto out;
}
+
+ buf = NULL;
i++;
}
@@ -2195,13 +2204,22 @@ glusterd_handle_snapshot_status (rpcsvc_request_t *req, glusterd_op_t op,
&volinfo->snap_volumes, snapvol_list) {
snprintf (key, sizeof (key), "snapname%d", i);
- ret = dict_set_str (dict, key,
- snap_volinfo->snapshot->snapname);
+ buf = gf_strdup
+ (snap_volinfo->snapshot->snapname);
+ if (!buf) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_set_dynstr (dict, key, buf);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"Could not save snapname");
+ GF_FREE (buf);
goto out;
}
+
+ buf = NULL;
i++;
}
@@ -2265,6 +2283,7 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op,
{
int ret = -1;
char *snapname = NULL;
+ char *buf = NULL;
glusterd_conf_t *conf = NULL;
xlator_t *this = NULL;
glusterd_snap_t *snap = NULL;
@@ -2299,12 +2318,19 @@ glusterd_handle_snapshot_restore (rpcsvc_request_t *req, glusterd_op_t op,
list_for_each_entry (snap_volinfo, &snap->volumes, vol_list) {
i++;
snprintf (key, sizeof (key), "volname%d", i);
- ret = dict_set_str (dict, key, snap_volinfo->parent_volname);
+ buf = gf_strdup (snap_volinfo->parent_volname);
+ if (!buf) {
+ ret = -1;
+ goto out;
+ }
+ ret = dict_set_dynstr (dict, key, buf);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Could not set "
"parent volume name");
+ GF_FREE (buf);
goto out;
}
+ buf = NULL;
}
ret = dict_set_int32 (dict, "volcount", i);