]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix strncat bounds error in libbpf_prog_type_by_name
authorKP Singh <kpsingh@google.com>
Wed, 23 Oct 2019 15:40:38 +0000 (17:40 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 23 Oct 2019 17:17:28 +0000 (10:17 -0700)
commit62d66cb412d754b49e9bb8bb607a5ce38893a88c
treeba8da2fe69745243100e76539a4e926f46e68a36
parent57d069bf9ab8ee4ab115651d931b9ed41665f05b
libbpf: Fix strncat bounds error in libbpf_prog_type_by_name

On compiling samples with this change, one gets an error:

 error: â€˜strncat’ specified bound 118 equals destination size
  [-Werror=stringop-truncation]

    strncat(dst, name + section_names[i].len,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     sizeof(raw_tp_btf_name) - (dst - raw_tp_btf_name));
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

strncat requires the destination to have enough space for the
terminating null byte.

Fixes: f78bc27827ab9 ("libbpf: Auto-detect btf_id of BTF-based raw_tracepoint")
Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191023154038.24075-1-kpsingh@chromium.org
tools/lib/bpf/libbpf.c