• Arnaldo Carvalho de Melo's avatar
    perf header: Fix unchecked usage of strncpy() · b0e6bdbf
    Arnaldo Carvalho de Melo authored
    [ Upstream commit 75725880 ]
    
    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_unit':
      util/header.c:3586: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->unit, size);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      util/header.c:3579:16: note: length computed here
        size_t size = strlen(evsel->unit);
                      ^~~~~~~~~~~~~~~~~~~
    
    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-fiikh5nay70bv4zskw2aa858@git.kernel.orgSigned-off-by: 's avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    b0e6bdbf
Name
Last commit
Last update
..
accounting Loading commit data...
arch Loading commit data...
bpf Loading commit data...
build Loading commit data...
cgroup Loading commit data...
crypto 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...
memory-model 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...
wmi Loading commit data...
Makefile Loading commit data...