diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2018-10-19 07:08:22 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-12-08 14:59:10 +0300 |
commit | 6235c229fea4e5c5fb35002a5ee1ae2dc65d3198 (patch) | |
tree | 22e9fe7a3866e7199f457dbb5664871fc4617ce4 /net/tipc | |
parent | 4e84cccacb1291fedd2518a7e074c3152705fd77 (diff) | |
download | linux-6235c229fea4e5c5fb35002a5ee1ae2dc65d3198.tar.xz |
tipc: use destination length for copy string
commit 29e270fc32192e7729057963ae7120663856c93e 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>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/topsrv.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c index 2627b5d812e9..b84c0059214f 100644 --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c @@ -657,7 +657,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); |