]>
Commit | Line | Data |
---|---|---|
11d71c9f GKH |
1 | From 29e270fc32192e7729057963ae7120663856c93e Mon Sep 17 00:00:00 2001 |
2 | From: Guoqing Jiang <gqjiang@suse.com> | |
3 | Date: Fri, 19 Oct 2018 12:08:22 +0800 | |
4 | Subject: tipc: use destination length for copy string | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | From: Guoqing Jiang <gqjiang@suse.com> | |
10 | ||
11 | commit 29e270fc32192e7729057963ae7120663856c93e upstream. | |
12 | ||
13 | Got below warning with gcc 8.2 compiler. | |
14 | ||
15 | net/tipc/topsrv.c: In function ‘tipc_topsrv_start’: | |
16 | net/tipc/topsrv.c:660:2: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] | |
17 | strncpy(srv->name, name, strlen(name) + 1); | |
18 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
19 | net/tipc/topsrv.c:660:27: note: length computed here | |
20 | strncpy(srv->name, name, strlen(name) + 1); | |
21 | ^~~~~~~~~~~~ | |
22 | So change it to correct length and use strscpy. | |
23 | ||
24 | Signed-off-by: Guoqing Jiang <gqjiang@suse.com> | |
25 | Acked-by: Ying Xue <ying.xue@windriver.com> | |
26 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
27 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
28 | ||
29 | --- | |
30 | net/tipc/subscr.c | 2 +- | |
31 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
32 | ||
33 | --- a/net/tipc/subscr.c | |
34 | +++ b/net/tipc/subscr.c | |
35 | @@ -337,7 +337,7 @@ int tipc_topsrv_start(struct net *net) | |
36 | topsrv->tipc_conn_new = tipc_subscrb_connect_cb; | |
37 | topsrv->tipc_conn_shutdown = tipc_subscrb_shutdown_cb; | |
38 | ||
39 | - strncpy(topsrv->name, name, strlen(name) + 1); | |
40 | + strscpy(topsrv->name, name, sizeof(topsrv->name)); | |
41 | tn->topsrv = topsrv; | |
42 | atomic_set(&tn->subscription_count, 0); | |
43 |