From patchwork Mon Jan 8 12:22:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongfeng Wang X-Patchwork-Id: 123696 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2649613qgn; Mon, 8 Jan 2018 04:17:26 -0800 (PST) X-Google-Smtp-Source: ACJfBovMbdupYG9MyU81FFSJngm1C9G/U2PU8xijbxcEUPanp7YtWm5Uo8f8kJj8aJJkxzDlCSFj X-Received: by 10.159.211.68 with SMTP id g4mr11786545plp.387.1515413846584; Mon, 08 Jan 2018 04:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515413846; cv=none; d=google.com; s=arc-20160816; b=1J/ny4lHqwg4TYxoBNT45/meRpXbvPf2kpgTdgOgR1fRaAMd6lkS4cxVzq95LrI+na Qmb+xOV8MeJ4tOnO3XdJmVxK+MVfpJBck2kVEdu7yCTubgi1aeoavVJtSzgP9HfzjRYW fPYBEROwBJsMf7kCwAa9GEbWQczDlZeretLgprIqziqOCtcFeXnktxEN1+ATha4ZSNk1 Zr/aPFQA95mPAa0G1IBOnqjfvAX9Xac4zp5PSLO7pMPp+u6hyLX95786lxXPi1tSyqgG algL51hZ8SucV6+HfYNhBPzPUP5bLAkIojAZSzm9U+geOz/3dMR7bCKE/fyRkIW+63c/ ZlLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=7VtyfFqJqqyj1oQ89NQA6ypbGYcQA9uknKq/l+3+pOQ=; b=MaqvhN4oNiAG/5XoIjRWCnMnEogMcH6SltcSqZPRSGA2CAuXbqCbQhKIdnlz8Bf1KT CZmglckOYTnkDu9qWvaa+UGE3oISFpQcKjfh3SG/5hHvbNzpausv/9MVilPdIkMCbUyX catOVqlc7Ld+Dmh3npINmE9/LCz7LTTvJFIQNaVw+IlyqkOGZquyniMJWR+i0wjeL7BE TZT//G41F+RwN/WLjzL7hw9XA5D8zFZ0yP+AeK+JPfD6xx32VKSYOftaNZNByE6GqAmD KePAEm/UwiBHwFxZPA2d53M+cnTNdC0ErObKY0J44OpUKjgzdvGxg3psm8aJuzIUg++4 KMrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w124si7419942pgb.569.2018.01.08.04.17.26; Mon, 08 Jan 2018 04:17:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757107AbeAHMRY (ORCPT + 28 others); Mon, 8 Jan 2018 07:17:24 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756046AbeAHMRX (ORCPT ); Mon, 8 Jan 2018 07:17:23 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2E441D750FE7; Mon, 8 Jan 2018 20:17:08 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Mon, 8 Jan 2018 20:16:58 +0800 From: Xiongfeng Wang To: CC: , , Subject: [PATCH] orangefs: use correct string length Date: Mon, 8 Jan 2018 20:22:33 +0800 Message-ID: <1515414153-49168-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiongfeng Wang 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 --- fs/orangefs/dcache.c | 2 +- fs/orangefs/namei.c | 16 ++++++++-------- fs/orangefs/super.c | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) -- 1.8.3.1 diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c index ae782df..be06e15 100644 --- a/fs/orangefs/dcache.c +++ b/fs/orangefs/dcache.c @@ -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", diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index c98bba2..6e3134e 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c @@ -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)); @@ -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", @@ -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)); @@ -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)); @@ -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)); @@ -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", diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index 36f1390..7ff17c4 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c @@ -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) @@ -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", @@ -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;