]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.54/perf-data-fix-strncat-may-truncate-build-failure-wit.patch
Linux 4.19.54
[thirdparty/kernel/stable-queue.git] / releases / 4.19.54 / perf-data-fix-strncat-may-truncate-build-failure-wit.patch
CommitLineData
a15a8890
SL
1From ad9dc0e3d1796e1337486a8859ee737a08c8a764 Mon Sep 17 00:00:00 2001
2From: Shawn Landden <shawn@git.icu>
3Date: Sat, 18 May 2019 15:32:38 -0300
4Subject: perf data: Fix 'strncat may truncate' build failure with recent gcc
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9[ Upstream commit 97acec7df172cd1e450f81f5e293c0aa145a2797 ]
10
11This strncat() is safe because the buffer was allocated with zalloc(),
12however gcc doesn't know that. Since the string always has 4 non-null
13bytes, just use memcpy() here.
14
15 CC /home/shawn/linux/tools/perf/util/data-convert-bt.o
16 In file included from /usr/include/string.h:494,
17 from /home/shawn/linux/tools/lib/traceevent/event-parse.h:27,
18 from util/data-convert-bt.c:22:
19 In function ‘strncat’,
20 inlined from ‘string_set_value’ at util/data-convert-bt.c:274:4:
21 /usr/include/powerpc64le-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation]
22 136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
23 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24
25Signed-off-by: Shawn Landden <shawn@git.icu>
26Cc: Adrian Hunter <adrian.hunter@intel.com>
27Cc: Jiri Olsa <jolsa@redhat.com>
28Cc: Namhyung Kim <namhyung@kernel.org>
29Cc: Wang Nan <wangnan0@huawei.com>
30LPU-Reference: 20190518183238.10954-1-shawn@git.icu
31Link: https://lkml.kernel.org/n/tip-289f1jice17ta7tr3tstm9jm@git.kernel.org
32Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
33Signed-off-by: Sasha Levin <sashal@kernel.org>
34---
35 tools/perf/util/data-convert-bt.c | 2 +-
36 1 file changed, 1 insertion(+), 1 deletion(-)
37
38diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
39index abd38abf1d91..24f2a87cf91d 100644
40--- a/tools/perf/util/data-convert-bt.c
41+++ b/tools/perf/util/data-convert-bt.c
42@@ -271,7 +271,7 @@ static int string_set_value(struct bt_ctf_field *field, const char *string)
43 if (i > 0)
44 strncpy(buffer, string, i);
45 }
46- strncat(buffer + p, numstr, 4);
47+ memcpy(buffer + p, numstr, 4);
48 p += 3;
49 }
50 }
51--
522.20.1
53