Skip to content

Commit 6235c22

Browse files
GuoqingJianggregkh
authored andcommitted
tipc: use destination length for copy string
commit 29e270f upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4e84ccc commit 6235c22

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/tipc/topsrv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ int tipc_topsrv_start(struct net *net)
657657
srv->max_rcvbuf_size = sizeof(struct tipc_subscr);
658658
INIT_WORK(&srv->awork, tipc_topsrv_accept);
659659

660-
strncpy(srv->name, name, strlen(name) + 1);
660+
strscpy(srv->name, name, sizeof(srv->name));
661661
tn->topsrv = srv;
662662
atomic_set(&tn->subscription_count, 0);
663663

0 commit comments

Comments
 (0)