mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 05:15:23 +02:00
tipc: fix -Wstringop-truncation warnings
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> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
parent
474c8749d7
commit
91024cb50b
|
@ -138,10 +138,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 */
|
||||
|
|
Loading…
Reference in New Issue
Block a user