From 76906af9d70fc784de728a70e3dbda62dece5e10 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLE" Date: Fri, 9 Nov 2018 11:27:11 -0500 Subject: core: fix strncpy warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since gcc-8.2.x (fedora-28 or so) gcc has been emitting warnings about buggy use of strncpy. e.g. warning: ‘strncpy’ output truncated before terminating nul copying as many bytes from a string as its length and warning: ‘strncpy’ specified bound depends on the length of the source argument Since we're copying string fragments and explicitly null terminating use memcpy to silence the warning Change-Id: I413d84b5f4157f15c99e9af3e154ce594d5bcdc1 updates: bz#1193929 Signed-off-by: Kaleb S. KEITHLEY --- xlators/mount/fuse/src/fuse-bridge.c | 2 +- xlators/mount/fuse/src/fuse-helpers.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'xlators/mount/fuse') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index 48b8d9df480..412c8ea158f 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -3491,7 +3491,7 @@ fuse_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, fde->dirent.off = entry->d_off; fde->dirent.type = entry->d_type; fde->dirent.namelen = strlen(entry->d_name); - strncpy(fde->dirent.name, entry->d_name, fde->dirent.namelen); + (void)memcpy(fde->dirent.name, entry->d_name, fde->dirent.namelen); size += FUSE_DIRENTPLUS_SIZE(fde); if (!entry->inode) diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c index 2145a951c4e..cf4f8e17c51 100644 --- a/xlators/mount/fuse/src/fuse-helpers.c +++ b/xlators/mount/fuse/src/fuse-helpers.c @@ -534,7 +534,7 @@ gf_fuse_fill_dirent(gf_dirent_t *entry, struct fuse_dirent *fde, fde->off = entry->d_off; fde->type = entry->d_type; fde->namelen = strlen(entry->d_name); - strncpy(fde->name, entry->d_name, fde->namelen); + (void)memcpy(fde->name, entry->d_name, fde->namelen); } static int -- cgit