• 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
..
Documentation Loading commit data...
arch Loading commit data...
bench Loading commit data...
jvmti Loading commit data...
pmu-events Loading commit data...
python Loading commit data...
scripts Loading commit data...
tests Loading commit data...
trace Loading commit data...
ui Loading commit data...
util Loading commit data...
.gitignore Loading commit data...
Build Loading commit data...
CREDITS Loading commit data...
MANIFEST Loading commit data...
Makefile Loading commit data...
Makefile.config Loading commit data...
Makefile.perf Loading commit data...
builtin-annotate.c Loading commit data...
builtin-bench.c Loading commit data...
builtin-buildid-cache.c Loading commit data...
builtin-buildid-list.c Loading commit data...
builtin-c2c.c Loading commit data...
builtin-config.c Loading commit data...
builtin-data.c Loading commit data...
builtin-diff.c Loading commit data...
builtin-evlist.c Loading commit data...
builtin-ftrace.c Loading commit data...
builtin-help.c Loading commit data...
builtin-inject.c Loading commit data...
builtin-kallsyms.c Loading commit data...
builtin-kmem.c Loading commit data...
builtin-kvm.c Loading commit data...
builtin-list.c Loading commit data...
builtin-lock.c Loading commit data...
builtin-mem.c Loading commit data...
builtin-probe.c Loading commit data...
builtin-record.c Loading commit data...
builtin-report.c Loading commit data...
builtin-sched.c Loading commit data...
builtin-script.c Loading commit data...
builtin-stat.c Loading commit data...
builtin-timechart.c Loading commit data...
builtin-top.c Loading commit data...
builtin-trace.c Loading commit data...
builtin-version.c Loading commit data...
builtin.h Loading commit data...
check-headers.sh Loading commit data...
command-list.txt Loading commit data...
design.txt Loading commit data...
perf-archive.sh Loading commit data...
perf-completion.sh Loading commit data...
perf-read-vdso.c Loading commit data...
perf-sys.h Loading commit data...
perf-with-kcore.sh Loading commit data...
perf.c Loading commit data...
perf.h Loading commit data...