diff options
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 1853028102c..ae2616342f4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -3668,10 +3668,10 @@ glusterd_copy_nfs_ganesha_file (glusterd_volinfo_t *src_vol, { int32_t ret = -1; - char snap_dir[PATH_MAX] = ""; - char src_path[PATH_MAX] = ""; - char dest_path[PATH_MAX] = ""; - char buffer[BUFSIZ] = ""; + char snap_dir[PATH_MAX] = {0,}; + char src_path[PATH_MAX] = {0,}; + char dest_path[PATH_MAX] = {0,}; + char buffer[BUFSIZ] = {0,}; char *find_ptr = NULL; char *buff_ptr = NULL; char *tmp_ptr = NULL; @@ -3692,16 +3692,14 @@ glusterd_copy_nfs_ganesha_file (glusterd_volinfo_t *src_vol, if (src_vol->is_snap_volume) { GLUSTERD_GET_SNAP_DIR (snap_dir, src_vol->snapshot, priv); - ret = snprintf (src_path, sizeof (src_path), - "%s/export.%s.conf", snap_dir, - src_vol->snapshot->snapname); + ret = snprintf (src_path, PATH_MAX, "%s/export.%s.conf", + snap_dir, src_vol->snapshot->snapname); } else { - ret = snprintf (src_path, sizeof (src_path), - "%s/export.%s.conf", GANESHA_EXPORT_DIRECTORY, - src_vol->volname); - if (ret < 0) - goto out; + ret = snprintf (src_path, PATH_MAX, "%s/export.%s.conf", + GANESHA_EXPORT_DIRECTORY, src_vol->volname); } + if (ret < 0 || ret >= PATH_MAX) + goto out; ret = sys_lstat (src_path, &stbuf); if (ret) { |