Skip to content

Commit

Permalink
orangefs: use correct string length
Browse files Browse the repository at this point in the history
gcc-8 reports

fs/orangefs/dcache.c: In function 'orangefs_d_revalidate':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 256 equals destination size [-Wstringop-truncation]

fs/orangefs/namei.c: In function 'orangefs_rename':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 256 equals destination size [-Wstringop-truncation]

fs/orangefs/super.c: In function 'orangefs_mount':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 256 equals destination size [-Wstringop-truncation]

We need one less byte or call strlcpy() to make it a nul-terminated
string.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
  • Loading branch information
Xiongfeng Wang authored and Mike Marshall committed Feb 6, 2018
1 parent 4d0cac7 commit 6bdfb48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion fs/orangefs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
new_op->upcall.req.lookup.parent_refn = parent->refn;
strncpy(new_op->upcall.req.lookup.d_name,
dentry->d_name.name,
ORANGEFS_NAME_MAX);
ORANGEFS_NAME_MAX - 1);

gossip_debug(GOSSIP_DCACHE_DEBUG,
"%s:%s:%d interrupt flag [%d]\n",
Expand Down
16 changes: 8 additions & 8 deletions fs/orangefs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static int orangefs_create(struct inode *dir,
ORANGEFS_TYPE_METAFILE, mode);

strncpy(new_op->upcall.req.create.d_name,
dentry->d_name.name, ORANGEFS_NAME_MAX);
dentry->d_name.name, ORANGEFS_NAME_MAX - 1);

ret = service_operation(new_op, __func__, get_interruptible_flag(dir));

Expand Down Expand Up @@ -142,7 +142,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
new_op->upcall.req.lookup.parent_refn = parent->refn;

strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
ORANGEFS_NAME_MAX);
ORANGEFS_NAME_MAX - 1);

gossip_debug(GOSSIP_NAME_DEBUG,
"%s: doing lookup on %s under %pU,%d\n",
Expand Down Expand Up @@ -244,7 +244,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)

new_op->upcall.req.remove.parent_refn = parent->refn;
strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
ORANGEFS_NAME_MAX);
ORANGEFS_NAME_MAX - 1);

ret = service_operation(new_op, "orangefs_unlink",
get_interruptible_flag(inode));
Expand Down Expand Up @@ -300,8 +300,8 @@ static int orangefs_symlink(struct inode *dir,

strncpy(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);
ORANGEFS_NAME_MAX - 1);
strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX - 1);

ret = service_operation(new_op, __func__, get_interruptible_flag(dir));

Expand Down Expand Up @@ -372,7 +372,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
ORANGEFS_TYPE_DIRECTORY, mode);

strncpy(new_op->upcall.req.mkdir.d_name,
dentry->d_name.name, ORANGEFS_NAME_MAX);
dentry->d_name.name, ORANGEFS_NAME_MAX - 1);

ret = service_operation(new_op, __func__, get_interruptible_flag(dir));

Expand Down Expand Up @@ -453,10 +453,10 @@ static int orangefs_rename(struct inode *old_dir,

strncpy(new_op->upcall.req.rename.d_old_name,
old_dentry->d_name.name,
ORANGEFS_NAME_MAX);
ORANGEFS_NAME_MAX - 1);
strncpy(new_op->upcall.req.rename.d_new_name,
new_dentry->d_name.name,
ORANGEFS_NAME_MAX);
ORANGEFS_NAME_MAX - 1);

ret = service_operation(new_op,
"orangefs_rename",
Expand Down
6 changes: 3 additions & 3 deletions fs/orangefs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
op->upcall.req.fs_umount.id = id;
op->upcall.req.fs_umount.fs_id = fs_id;
strncpy(op->upcall.req.fs_umount.orangefs_config_server,
devname, ORANGEFS_MAX_SERVER_ADDR_LEN);
devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
r = service_operation(op, "orangefs_fs_umount", 0);
/* Not much to do about an error here. */
if (r)
Expand Down Expand Up @@ -478,7 +478,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,

strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
devname,
ORANGEFS_MAX_SERVER_ADDR_LEN);
ORANGEFS_MAX_SERVER_ADDR_LEN - 1);

gossip_debug(GOSSIP_SUPER_DEBUG,
"Attempting ORANGEFS Mount via host %s\n",
Expand Down Expand Up @@ -520,7 +520,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
*/
strncpy(ORANGEFS_SB(sb)->devname,
devname,
ORANGEFS_MAX_SERVER_ADDR_LEN);
ORANGEFS_MAX_SERVER_ADDR_LEN - 1);

/* mount_pending must be cleared */
ORANGEFS_SB(sb)->mount_pending = 0;
Expand Down

0 comments on commit 6bdfb48

Please sign in to comment.