summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src/nfs-inodes.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-21 20:29:17 +0300
committerAmar Tumballi <amarts@redhat.com>2018-08-31 06:17:20 +0000
commitcd1051789361bd07e248baf1bf0fbbe479cd4ae1 (patch)
tree97a0b5bc7b3f93dd3ed79dee38e106c987d73001 /xlators/nfs/server/src/nfs-inodes.c
parenta1d61242baed1c2078707c401632719e756fcacb (diff)
NFS server (mount3.c, nfs-inodes.c): strncpy()->sprintf(), reduce strlen()'s
xlators/nfs/server/src/mount3.c xlators/nfs/server/src/nfs-inodes.c strncpy may not be very efficient for short strings copied into a large buffer: If the length of src is less than n, strncpy() writes additional null bytes to dest to ensure that a total of n bytes are written. Instead, use snprintf(). Compile-tested only! Change-Id: Ibe74ccdb67434e9a10fc1f21c0b4cd5e4b8cb589 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators/nfs/server/src/nfs-inodes.c')
-rw-r--r--xlators/nfs/server/src/nfs-inodes.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/xlators/nfs/server/src/nfs-inodes.c b/xlators/nfs/server/src/nfs-inodes.c
index 515622a3d5c..91703c70a1f 100644
--- a/xlators/nfs/server/src/nfs-inodes.c
+++ b/xlators/nfs/server/src/nfs-inodes.c
@@ -43,11 +43,10 @@ nfl_inodes_init (struct nfs_fop_local *nfl, inode_t *inode, inode_t *parent,
nfl->newparent = inode_ref (newparent);
if (name)
- strncpy (nfl->path, name, NFS_NAME_MAX);
+ snprintf (nfl->path, NFS_NAME_MAX, "%s", name);
if (newname)
- strncpy (nfl->newpath, newname, NFS_NAME_MAX);
-
+ snprintf (nfl->newpath, NFS_NAME_MAX, "%s", newname);
return;
}