]> git.baikalelectronics.ru Git - kernel.git/commit
tipc: use destination length for copy string
authorGuoqing Jiang <gqjiang@suse.com>
Fri, 19 Oct 2018 04:08:22 +0000 (12:08 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 23 Oct 2018 02:25:32 +0000 (19:25 -0700)
commit86a5eddc8d4a0eae3d64a764f230e0dcbe99579e
tree2d0c82a21d7fd117bef62e8f17b357f9ab59f0a9
parent70af5ef36a07b9801493c49781a13c7d6dab45f4
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>
net/tipc/topsrv.c