[PATCH 2/3] orangefs: strncpy -> strlcpy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Brandenburg <martin@xxxxxxxxxxxx>

Almost everywhere we use strncpy we should use strlcpy. This affects
path names (d_name mostly), symlink targets, and server names.

Leave debugfs code as is for now, though it could use a review as well.

Signed-off-by: Martin Brandenburg <martin@xxxxxxxxxxxx>
---
 fs/orangefs/dcache.c         |  2 +-
 fs/orangefs/namei.c          | 16 ++++++++--------
 fs/orangefs/orangefs-utils.c |  2 +-
 fs/orangefs/super.c          |  6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c
index 5dfc4f3..0710869 100644
--- a/fs/orangefs/dcache.c
+++ b/fs/orangefs/dcache.c
@@ -30,7 +30,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
 
 	new_op->upcall.req.lookup.sym_follow = ORANGEFS_LOOKUP_LINK_NO_FOLLOW;
 	new_op->upcall.req.lookup.parent_refn = parent->refn;
-	strncpy(new_op->upcall.req.lookup.d_name,
+	strlcpy(new_op->upcall.req.lookup.d_name,
 		dentry->d_name.name,
 		ORANGEFS_NAME_MAX);
 
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 5a60c50..fc7e948 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -37,7 +37,7 @@ static int orangefs_create(struct inode *dir,
 	fill_default_sys_attrs(new_op->upcall.req.create.attributes,
 			       ORANGEFS_TYPE_METAFILE, mode);
 
-	strncpy(new_op->upcall.req.create.d_name,
+	strlcpy(new_op->upcall.req.create.d_name,
 		dentry->d_name.name, ORANGEFS_NAME_MAX);
 
 	ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
@@ -132,7 +132,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
 		     &parent->refn.khandle);
 	new_op->upcall.req.lookup.parent_refn = parent->refn;
 
-	strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
+	strlcpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
 		ORANGEFS_NAME_MAX);
 
 	gossip_debug(GOSSIP_NAME_DEBUG,
@@ -231,7 +231,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
 		return -ENOMEM;
 
 	new_op->upcall.req.remove.parent_refn = parent->refn;
-	strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
+	strlcpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
 		ORANGEFS_NAME_MAX);
 
 	ret = service_operation(new_op, "orangefs_unlink",
@@ -282,10 +282,10 @@ static int orangefs_symlink(struct inode *dir,
 			       ORANGEFS_TYPE_SYMLINK,
 			       mode);
 
-	strncpy(new_op->upcall.req.sym.entry_name,
+	strlcpy(new_op->upcall.req.sym.entry_name,
 		dentry->d_name.name,
 		ORANGEFS_NAME_MAX);
-	strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX);
+	strlcpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX);
 
 	ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
 
@@ -347,7 +347,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
 	fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes,
 			      ORANGEFS_TYPE_DIRECTORY, mode);
 
-	strncpy(new_op->upcall.req.mkdir.d_name,
+	strlcpy(new_op->upcall.req.mkdir.d_name,
 		dentry->d_name.name, ORANGEFS_NAME_MAX);
 
 	ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
@@ -419,10 +419,10 @@ static int orangefs_rename(struct inode *old_dir,
 	new_op->upcall.req.rename.old_parent_refn = ORANGEFS_I(old_dir)->refn;
 	new_op->upcall.req.rename.new_parent_refn = ORANGEFS_I(new_dir)->refn;
 
-	strncpy(new_op->upcall.req.rename.d_old_name,
+	strlcpy(new_op->upcall.req.rename.d_old_name,
 		old_dentry->d_name.name,
 		ORANGEFS_NAME_MAX);
-	strncpy(new_op->upcall.req.rename.d_new_name,
+	strlcpy(new_op->upcall.req.rename.d_new_name,
 		new_dentry->d_name.name,
 		ORANGEFS_NAME_MAX);
 
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index 40f5163..d72f3fc 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -505,7 +505,7 @@ int orangefs_unmount_sb(struct super_block *sb)
 		return -ENOMEM;
 	new_op->upcall.req.fs_umount.id = ORANGEFS_SB(sb)->id;
 	new_op->upcall.req.fs_umount.fs_id = ORANGEFS_SB(sb)->fs_id;
-	strncpy(new_op->upcall.req.fs_umount.orangefs_config_server,
+	strlcpy(new_op->upcall.req.fs_umount.orangefs_config_server,
 		ORANGEFS_SB(sb)->devname,
 		ORANGEFS_MAX_SERVER_ADDR_LEN);
 
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index b9da9a0..5f9a4ff 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -220,7 +220,7 @@ int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)
 	new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
 	if (!new_op)
 		return -ENOMEM;
-	strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
+	strlcpy(new_op->upcall.req.fs_mount.orangefs_config_server,
 		orangefs_sb->devname,
 		ORANGEFS_MAX_SERVER_ADDR_LEN);
 
@@ -434,7 +434,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	if (!new_op)
 		return ERR_PTR(-ENOMEM);
 
-	strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
+	strlcpy(new_op->upcall.req.fs_mount.orangefs_config_server,
 		devname,
 		ORANGEFS_MAX_SERVER_ADDR_LEN);
 
@@ -474,7 +474,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 	 * on successful mount, store the devname and data
 	 * used
 	 */
-	strncpy(ORANGEFS_SB(sb)->devname,
+	strlcpy(ORANGEFS_SB(sb)->devname,
 		devname,
 		ORANGEFS_MAX_SERVER_ADDR_LEN);
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux