summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2015-04-15 09:15:23 +0200
committerNiels de Vos <ndevos@redhat.com>2015-04-18 12:15:47 +0000
commitfc451b5b0fb8d7b3952ca6ecf91779cbcf00187f (patch)
tree8547ddd576155ee0fd69a604af20143c8d0c17f3
parent7fb85e3670cb4743436fd2cf0fbbf9c0869728ec (diff)
gfapi: fix potential non-0-terminated string (CID 1134002)
Use correct target buffer length for strncpy and make sure that the target string is 0 terminated. Fixes Coverity ID 1134002. Change-Id: I97a74a94a818eb08a711e547f2ac6ae46087f065 BUG: 789278 Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-on: http://review.gluster.org/10247 Tested-by: NetBSD Build System Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kotresh HR <khiremat@redhat.com> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--api/src/glfs-fops.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index ba95e021ee2..de5be43f435 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -2062,7 +2062,8 @@ gf_dirent_to_dirent (gf_dirent_t *gf_dirent, struct dirent *dirent)
dirent->d_namlen = strlen (gf_dirent->d_name);
#endif
- strncpy (dirent->d_name, gf_dirent->d_name, GF_NAME_MAX + 1);
+ strncpy (dirent->d_name, gf_dirent->d_name, NAME_MAX);
+ dirent->d_name[NAME_MAX] = 0;
}