Message ID | 20201112093442.8132-1-wenlin.kang@windriver.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 2f51e5758d61d37e517b809051048c6d0118ab41 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | tipc: fix -Wstringop-truncation warnings | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | warning | Target tree name not specified in the subject |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 18 this patch: 17 |
netdev/kdoc | success | Errors and warnings before: 17 this patch: 17 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 11 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 17 this patch: 17 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On 11/12/20 5:34 PM, Kang Wenlin wrote: > From: Wenlin Kang <wenlin.kang@windriver.com> > > 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:141: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> Acked-by: Ying Xue <ying.xue@windriver.com> > --- > net/tipc/bearer.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c > index 650414110452..2241d5a38f7b 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 */ >
Hello: This patch was applied to netdev/net-next.git (refs/heads/master): On Thu, 12 Nov 2020 17:34:42 +0800 you wrote: > From: Wenlin Kang <wenlin.kang@windriver.com> > > 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:141:2: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation] > strncpy(name_copy, name, TIPC_MAX_BEARER_NAME); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > [...] Here is the summary with links: - tipc: fix -Wstringop-truncation warnings https://git.kernel.org/netdev/net-next/c/2f51e5758d61 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 650414110452..2241d5a38f7b 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 */