• Arnaldo Carvalho de Melo's avatar
    perf probe: Fix unchecked usage of strncpy() · 9c10d5b2
    Arnaldo Carvalho de Melo authored
    [ Upstream commit bef0b897 ]
    
    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 the 'target' buffer is coming from a list of build-ids that
    are expected to have a len of at most (SBUILD_ID_SIZE - 1) chars, so
    probably we're safe, but since we're using strncpy() here, use strlcpy()
    instead to provide the intended safety checking without the using the
    problematic strncpy() function.
    
    This fixes this warning on an Alpine Linux Edge system with gcc 8.2:
    
      util/probe-file.c: In function 'probe_cache__open.isra.5':
      util/probe-file.c:427:3: error: 'strncpy' specified bound 41 equals destination size [-Werror=stringop-truncation]
         strncpy(sbuildid, target, SBUILD_ID_SIZE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      cc1: all warnings being treated as errors
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Fixes: 1f3736c9 ("perf probe: Show all cached probes")
    Link: https://lkml.kernel.org/n/tip-l7n8ggc9kl38qtdlouke5yp5@git.kernel.orgSigned-off-by: 's avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    9c10d5b2
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...