• Arnaldo Carvalho de Melo's avatar
    perf header: Fix unchecked usage of strncpy() · 2a2e3b98
    Arnaldo Carvalho de Melo authored
    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: a6e52817 ("perf tools: Add event_update event unit type")
    Link: https://lkml.kernel.org/n/tip-wycz66iy8dl2z3yifgqf894p@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    2a2e3b98
Name
Last commit
Last update
..
accounting Loading commit data...
arch Loading commit data...
build Loading commit data...
cgroup Loading commit data...
firewire Loading commit data...
gpio Loading commit data...
hv Loading commit data...
iio Loading commit data...
include Loading commit data...
kvm/kvm_stat Loading commit data...
laptop Loading commit data...
leds Loading commit data...
lib Loading commit data...
net Loading commit data...
nfsd Loading commit data...
objtool Loading commit data...
pci Loading commit data...
pcmcia Loading commit data...
perf Loading commit data...
power Loading commit data...
scripts Loading commit data...
spi Loading commit data...
testing Loading commit data...
thermal/tmon Loading commit data...
time Loading commit data...
usb Loading commit data...
virtio Loading commit data...
vm Loading commit data...
Makefile Loading commit data...