summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
diff options
context:
space:
mode:
authorKaleb S KEITHLEY <kkeithle@redhat.com>2016-02-22 11:02:31 -0500
committerKaleb KEITHLEY <kkeithle@redhat.com>2016-02-23 08:44:37 -0800
commitec6eb8200e41dadc623fd2341a3c5cf8cc71dec7 (patch)
treefeb93cd81e77ecc26dbd2d0c8dde9e4b361fc03d /xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
parent0bc54f3ea7a56040df4a67b8626200b47fa3d779 (diff)
glusterd: coverity warning in glusted_copy_nfs_ganesha_file()
fix unused return value from snprintf. Also minor cleanup, including safe handling of truncated output by snprintf. Change-Id: Ibec8c7e6cc4ef07b6535d01a0719359fa3ef8030 BUG: 1310755 Signed-off-by: Kaleb S KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/13486 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c22
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) {