aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWenlin Kang <wenlin.kang@windriver.com>2020-11-15 18:58:09 -0800
committerBruce Ashfield <bruce.ashfield@gmail.com>2020-11-19 10:20:11 -0500
commit3c5d210805d61bea8f8a8081e0e3a89ea8a61f3f (patch)
treea2edb4f3b3a13da29395b8d12760ae5f3e9441bc
parentcc89fd77c2484438724bf8fb3f8af163357d5377 (diff)
downloadlinux-yocto-v5.8/standard/qemuarm64.tar.gz
linux-yocto-v5.8/standard/qemuarm64.tar.bz2
linux-yocto-v5.8/standard/qemuarm64.zip
Replace strncpy() with strscpy(), fixes the following warning: In function 'bearer_name_validate', inlined from 'tipc_enable_bearer' at net/tipc/bearer.c:246:7: net/tipc/bearer.c:143:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation] strncpy(name_copy, name, TIPC_MAX_BEARER_NAME); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Wenlin Kang <wenlin.kang@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--net/tipc/bearer.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index e366ec9a7e4d..c5896730e393 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -139,10 +139,7 @@ static int bearer_name_validate(const char *name,
u32 if_len;
/* copy bearer name & ensure length is OK */
- name_copy[TIPC_MAX_BEARER_NAME - 1] = 0;
- /* need above in case non-Posix strncpy() doesn't pad with nulls */
- strncpy(name_copy, name, TIPC_MAX_BEARER_NAME);
- if (name_copy[TIPC_MAX_BEARER_NAME - 1] != 0)
+ if (strscpy(name_copy, name, TIPC_MAX_BEARER_NAME) < 0)
return 0;
/* ensure all component parts of bearer name are present */