]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/perf-help-remove-needless-use-of-strncpy.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / perf-help-remove-needless-use-of-strncpy.patch
1 From b6313899f4ed2e76b8375cf8069556f5b94fbff0 Mon Sep 17 00:00:00 2001
2 From: Arnaldo Carvalho de Melo <acme@redhat.com>
3 Date: Thu, 6 Dec 2018 11:20:21 -0300
4 Subject: perf help: Remove needless use of strncpy()
5
6 From: Arnaldo Carvalho de Melo <acme@redhat.com>
7
8 commit b6313899f4ed2e76b8375cf8069556f5b94fbff0 upstream.
9
10 Since we make sure the destination buffer has at least strlen(orig) + 1,
11 no need to do a strncpy(dest, orig, strlen(orig)), just use strcpy(dest,
12 orig).
13
14 This silences this gcc 8.2 warning on Alpine Linux:
15
16 In function 'add_man_viewer',
17 inlined from 'perf_help_config' at builtin-help.c:284:3:
18 builtin-help.c:192:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
19 strncpy((*p)->name, name, len);
20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21 builtin-help.c: In function 'perf_help_config':
22 builtin-help.c:187:15: note: length computed here
23 size_t len = strlen(name);
24 ^~~~~~~~~~~~
25
26 Cc: Adrian Hunter <adrian.hunter@intel.com>
27 Cc: Jiri Olsa <jolsa@kernel.org>
28 Cc: Namhyung Kim <namhyung@kernel.org>
29 Fixes: 078006012401 ("perf_counter tools: add in basic glue from Git")
30 Link: https://lkml.kernel.org/n/tip-2f69l7drca427ob4km8i7kvo@git.kernel.org
31 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34 ---
35 tools/perf/builtin-help.c | 2 +-
36 1 file changed, 1 insertion(+), 1 deletion(-)
37
38 --- a/tools/perf/builtin-help.c
39 +++ b/tools/perf/builtin-help.c
40 @@ -179,7 +179,7 @@ static void add_man_viewer(const char *n
41 while (*p)
42 p = &((*p)->next);
43 *p = zalloc(sizeof(**p) + len + 1);
44 - strncpy((*p)->name, name, len);
45 + strcpy((*p)->name, name);
46 }
47
48 static int supported_man_viewer(const char *name, size_t len)