--- /dev/null
+From 5192bde7d98c99f2cd80225649e3c2e7493722f7 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Thu, 6 Dec 2018 11:09:46 -0300
+Subject: perf header: Fix unchecked usage of strncpy()
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit 5192bde7d98c99f2cd80225649e3c2e7493722f7 upstream.
+
+The strncpy() function may leave the destination string buffer
+unterminated, better use strlcpy() that we have a __weak fallback
+implementation for systems without it.
+
+This fixes this warning on an Alpine Linux Edge system with gcc 8.2:
+
+ util/header.c: In function 'perf_event__synthesize_event_update_name':
+ util/header.c:3625:2: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
+ strncpy(ev->data, evsel->name, len);
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ util/header.c:3618:15: note: length computed here
+ size_t len = strlen(evsel->name);
+ ^~~~~~~~~~~~~~~~~~~
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Fixes: a6e5281780d1 ("perf tools: Add event_update event unit type")
+Link: https://lkml.kernel.org/n/tip-wycz66iy8dl2z3yifgqf894p@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/util/header.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/perf/util/header.c
++++ b/tools/perf/util/header.c
+@@ -3562,7 +3562,7 @@ perf_event__synthesize_event_update_name
+ if (ev == NULL)
+ return -ENOMEM;
+
+- strncpy(ev->data, evsel->name, len);
++ strlcpy(ev->data, evsel->name, len + 1);
+ err = process(tool, (union perf_event*) ev, NULL, NULL);
+ free(ev);
+ return err;
--- /dev/null
+From b6313899f4ed2e76b8375cf8069556f5b94fbff0 Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Thu, 6 Dec 2018 11:20:21 -0300
+Subject: perf help: Remove needless use of strncpy()
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit b6313899f4ed2e76b8375cf8069556f5b94fbff0 upstream.
+
+Since we make sure the destination buffer has at least strlen(orig) + 1,
+no need to do a strncpy(dest, orig, strlen(orig)), just use strcpy(dest,
+orig).
+
+This silences this gcc 8.2 warning on Alpine Linux:
+
+ In function 'add_man_viewer',
+ inlined from 'perf_help_config' at builtin-help.c:284:3:
+ 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]
+ strncpy((*p)->name, name, len);
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ builtin-help.c: In function 'perf_help_config':
+ builtin-help.c:187:15: note: length computed here
+ size_t len = strlen(name);
+ ^~~~~~~~~~~~
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Fixes: 078006012401 ("perf_counter tools: add in basic glue from Git")
+Link: https://lkml.kernel.org/n/tip-2f69l7drca427ob4km8i7kvo@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/builtin-help.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/perf/builtin-help.c
++++ b/tools/perf/builtin-help.c
+@@ -189,7 +189,7 @@ static void add_man_viewer(const char *n
+ while (*p)
+ p = &((*p)->next);
+ *p = zalloc(sizeof(**p) + len + 1);
+- strncpy((*p)->name, name, len);
++ strcpy((*p)->name, name);
+ }
+
+ static int supported_man_viewer(const char *name, size_t len)
--- /dev/null
+From 4d0f16d059ddb91424480d88473f7392f24aebdc Mon Sep 17 00:00:00 2001
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+Date: Thu, 6 Dec 2018 11:41:03 -0300
+Subject: perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul
+
+From: Arnaldo Carvalho de Melo <acme@redhat.com>
+
+commit 4d0f16d059ddb91424480d88473f7392f24aebdc upstream.
+
+The strncpy() function may leave the destination string buffer
+unterminated, better use strlcpy() that we have a __weak fallback
+implementation for systems without it.
+
+In this case we are actually setting the null byte at the right place,
+but since we pass the buffer size as the limit to strncpy() and not
+it minus one, gcc ends up warning us about that, see below. So, lets
+just switch to the shorter form provided by strlcpy().
+
+This fixes this warning on an Alpine Linux Edge system with gcc 8.2:
+
+ ui/tui/helpline.c: In function 'tui_helpline__push':
+ ui/tui/helpline.c:27:2: error: 'strncpy' specified bound 512 equals destination size [-Werror=stringop-truncation]
+ strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0';
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ cc1: all warnings being treated as errors
+
+Cc: Adrian Hunter <adrian.hunter@intel.com>
+Cc: Jiri Olsa <jolsa@kernel.org>
+Cc: Namhyung Kim <namhyung@kernel.org>
+Fixes: e6e904687949 ("perf ui: Introduce struct ui_helpline")
+Link: https://lkml.kernel.org/n/tip-d1wz0hjjsh19xbalw69qpytj@git.kernel.org
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/ui/tui/helpline.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/perf/ui/tui/helpline.c
++++ b/tools/perf/ui/tui/helpline.c
+@@ -24,7 +24,7 @@ static void tui_helpline__push(const cha
+ SLsmg_set_color(0);
+ SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols);
+ SLsmg_refresh();
+- strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0';
++ strlcpy(ui_helpline__current, msg, sz);
+ }
+
+ static int tui_helpline__show(const char *format, va_list ap)
--- /dev/null
+perf-ui-helpline-use-strlcpy-as-a-shorter-form-of-strncpy-explicit-set-nul.patch
+perf-help-remove-needless-use-of-strncpy.patch
+perf-header-fix-unchecked-usage-of-strncpy.patch