]>
Commit | Line | Data |
---|---|---|
13e8e92f GKH |
1 | From foo@baz Mon Sep 17 12:22:41 CEST 2018 |
2 | From: Marcel Holtmann <marcel@holtmann.org> | |
3 | Date: Mon, 30 Jul 2018 13:57:41 +0200 | |
4 | Subject: Bluetooth: hidp: Fix handling of strncpy for hid->name information | |
5 | ||
6 | From: Marcel Holtmann <marcel@holtmann.org> | |
7 | ||
8 | [ Upstream commit b3cadaa485f0c20add1644a5c877b0765b285c0c ] | |
9 | ||
10 | This fixes two issues with setting hid->name information. | |
11 | ||
12 | CC net/bluetooth/hidp/core.o | |
13 | In function ‘hidp_setup_hid’, | |
14 | inlined from ‘hidp_session_dev_init’ at net/bluetooth/hidp/core.c:815:9, | |
15 | inlined from ‘hidp_session_new’ at net/bluetooth/hidp/core.c:953:8, | |
16 | inlined from ‘hidp_connection_add’ at net/bluetooth/hidp/core.c:1366:8: | |
17 | net/bluetooth/hidp/core.c:778:2: warning: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 127 [-Wstringop-truncation] | |
18 | strncpy(hid->name, req->name, sizeof(req->name) - 1); | |
19 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
20 | ||
21 | CC net/bluetooth/hidp/core.o | |
22 | net/bluetooth/hidp/core.c: In function ‘hidp_setup_hid’: | |
23 | net/bluetooth/hidp/core.c:778:38: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess] | |
24 | strncpy(hid->name, req->name, sizeof(req->name)); | |
25 | ^ | |
26 | ||
27 | Signed-off-by: Marcel Holtmann <marcel@holtmann.org> | |
28 | Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> | |
29 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
30 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
31 | --- | |
32 | net/bluetooth/hidp/core.c | 2 +- | |
33 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
34 | ||
35 | --- a/net/bluetooth/hidp/core.c | |
36 | +++ b/net/bluetooth/hidp/core.c | |
37 | @@ -774,7 +774,7 @@ static int hidp_setup_hid(struct hidp_se | |
38 | hid->version = req->version; | |
39 | hid->country = req->country; | |
40 | ||
41 | - strncpy(hid->name, req->name, sizeof(req->name) - 1); | |
42 | + strncpy(hid->name, req->name, sizeof(hid->name)); | |
43 | ||
44 | snprintf(hid->phys, sizeof(hid->phys), "%pMR", | |
45 | &l2cap_pi(session->ctrl_sock->sk)->chan->src); |