mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 14:41:02 +07:00
tipc: use destination length for copy string
Got below warning with gcc 8.2 compiler. net/tipc/topsrv.c: In function ‘tipc_topsrv_start’: net/tipc/topsrv.c:660:2: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] strncpy(srv->name, name, strlen(name) + 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/tipc/topsrv.c:660:27: note: length computed here strncpy(srv->name, name, strlen(name) + 1); ^~~~~~~~~~~~ So change it to correct length and use strscpy. Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a1930a9877
commit
29e270fc32
@ -651,7 +651,7 @@ int tipc_topsrv_start(struct net *net)
|
||||
srv->max_rcvbuf_size = sizeof(struct tipc_subscr);
|
||||
INIT_WORK(&srv->awork, tipc_topsrv_accept);
|
||||
|
||||
strncpy(srv->name, name, strlen(name) + 1);
|
||||
strscpy(srv->name, name, sizeof(srv->name));
|
||||
tn->topsrv = srv;
|
||||
atomic_set(&tn->subscription_count, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user