]>
Commit | Line | Data |
---|---|---|
a15a8890 SL |
1 | From ad9dc0e3d1796e1337486a8859ee737a08c8a764 Mon Sep 17 00:00:00 2001 |
2 | From: Shawn Landden <shawn@git.icu> | |
3 | Date: Sat, 18 May 2019 15:32:38 -0300 | |
4 | Subject: perf data: Fix 'strncat may truncate' build failure with recent gcc | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | [ Upstream commit 97acec7df172cd1e450f81f5e293c0aa145a2797 ] | |
10 | ||
11 | This strncat() is safe because the buffer was allocated with zalloc(), | |
12 | however gcc doesn't know that. Since the string always has 4 non-null | |
13 | bytes, 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 | ||
25 | Signed-off-by: Shawn Landden <shawn@git.icu> | |
26 | Cc: Adrian Hunter <adrian.hunter@intel.com> | |
27 | Cc: Jiri Olsa <jolsa@redhat.com> | |
28 | Cc: Namhyung Kim <namhyung@kernel.org> | |
29 | Cc: Wang Nan <wangnan0@huawei.com> | |
30 | LPU-Reference: 20190518183238.10954-1-shawn@git.icu | |
31 | Link: https://lkml.kernel.org/n/tip-289f1jice17ta7tr3tstm9jm@git.kernel.org | |
32 | Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> | |
33 | Signed-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 | ||
38 | diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c | |
39 | index 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 | -- | |
52 | 2.20.1 | |
53 |