]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.7/veth-fix-wformat-truncation.patch
Linux 5.0.7
[thirdparty/kernel/stable-queue.git] / releases / 5.0.7 / veth-fix-wformat-truncation.patch
1 From 7adc62d0b8f2429b65ffe0abe70729202542f3a2 Mon Sep 17 00:00:00 2001
2 From: Florian Fainelli <f.fainelli@gmail.com>
3 Date: Thu, 21 Feb 2019 20:09:29 -0800
4 Subject: veth: Fix -Wformat-truncation
5
6 [ Upstream commit abdf47aab4123ece48877cab4153db44fe4dc340 ]
7
8 Provide a precision hint to snprintf() in order to eliminate a
9 -Wformat-truncation warning provided below. A maximum of 11 characters
10 is allowed to reach a maximum of 32 - 1 characters given a possible
11 maximum value of queues using up to UINT_MAX which occupies 10
12 characters. Incidentally 11 is the number of characters for
13 "xdp_packets" which is the largest string we append.
14
15 drivers/net/veth.c: In function 'veth_get_strings':
16 drivers/net/veth.c:118:47: warning: '%s' directive output may be
17 truncated writing up to 31 bytes into a region of size between 12 and 21
18 [-Wformat-truncation=]
19 snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s",
20 ^~
21 drivers/net/veth.c:118:5: note: 'snprintf' output between 12 and 52
22 bytes into a destination of size 32
23 snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s",
24 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 i, veth_rq_stats_desc[j].desc);
26 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
28 Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
29 Signed-off-by: David S. Miller <davem@davemloft.net>
30 Signed-off-by: Sasha Levin <sashal@kernel.org>
31 ---
32 drivers/net/veth.c | 3 ++-
33 1 file changed, 2 insertions(+), 1 deletion(-)
34
35 diff --git a/drivers/net/veth.c b/drivers/net/veth.c
36 index f412ea1cef18..b203d1867959 100644
37 --- a/drivers/net/veth.c
38 +++ b/drivers/net/veth.c
39 @@ -115,7 +115,8 @@ static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
40 p += sizeof(ethtool_stats_keys);
41 for (i = 0; i < dev->real_num_rx_queues; i++) {
42 for (j = 0; j < VETH_RQ_STATS_LEN; j++) {
43 - snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s",
44 + snprintf(p, ETH_GSTRING_LEN,
45 + "rx_queue_%u_%.11s",
46 i, veth_rq_stats_desc[j].desc);
47 p += ETH_GSTRING_LEN;
48 }
49 --
50 2.19.1
51