linux/tools
Arnaldo Carvalho de Melo 02cef97b6a perf parse-events: Fix unchecked usage of strncpy()
commit bd8d57fb7e 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/parse-events.c: In function 'print_symbol_events':
  util/parse-events.c:2465:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
      strncpy(name, syms->symbol, MAX_NAME_LEN);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function 'print_symbol_events.constprop',
      inlined from 'print_events' at util/parse-events.c:2508:2:
  util/parse-events.c:2465:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
      strncpy(name, syms->symbol, MAX_NAME_LEN);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In function 'print_symbol_events.constprop',
      inlined from 'print_events' at util/parse-events.c:2511:2:
  util/parse-events.c:2465:4: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
      strncpy(name, syms->symbol, MAX_NAME_LEN);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  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: 947b4ad1d1 ("perf list: Fix max event string size")
Link: https://lkml.kernel.org/n/tip-b663e33bm6x8hrkie4uxh7u2@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2019-04-04 16:13:52 +01:00
..
arch/x86/include/asm perf tools: Move syscall number fallbacks from perf-sys.h to tools/arch/x86/include/asm/ 2018-11-20 18:06:03 +00:00
cgroup cgroups: fix cgroup_event_listener error handling 2013-01-08 10:00:44 -08:00
firewire tools/firewire: nosy-dump: check for allocation failure 2012-12-02 20:10:18 +01:00
hv tools: hv: fcopy: set 'error' in case an unknown operation was requested 2018-12-16 22:09:31 +00:00
include tools include: Add a __fallthrough statement 2018-11-20 18:06:05 +00:00
lguest tools/lguest: offer VIRTIO_F_ANY_LAYOUT for net device. 2013-07-15 11:18:32 +09:30
lib tools/lib/lockdep: Rename "trywlock" into "trywrlock" 2019-04-04 16:13:48 +01:00
net tools/net: Use include/uapi with __EXPORTED_HEADERS__ 2015-12-14 10:17:12 +00:00
nfsd NFSD: Added fault injection script 2011-11-07 21:10:47 -05:00
perf perf parse-events: Fix unchecked usage of strncpy() 2019-04-04 16:13:52 +01:00
power cpupower: remove stringop-truncation waring 2019-02-11 17:53:16 +00:00
scripts tools lib traceevent: Add global QUIET_CC_FPIC build output 2013-12-19 16:18:10 -03:00
testing rcutorture/kvm.sh: Use consistent help text for --qemu-args 2018-06-16 22:21:43 +01:00
thermal/tmon tmon: set umask to a reasonable value 2014-07-01 22:00:51 +08:00
usb tools: ffs-test: fix header values endianess 2014-06-30 13:23:58 -05:00
virtio tools: Consolidate types.h 2014-05-01 21:22:39 +02:00
vm tools/vm/slabinfo: fix an unintentional printf 2016-11-20 01:16:57 +00:00
Makefile tools: Add a "make all" rule 2016-01-25 10:43:31 +00:00