diff options
author | Ian Rogers <[email protected]> | 2020-10-27 16:36:45 -0700 |
---|---|---|
committer | Daniel Borkmann <[email protected]> | 2020-10-29 15:22:57 +0100 |
commit | 1e6f5dcc1b9ec9068f5d38331cec38b35498edf5 (patch) | |
tree | 955203bc8e6520b09ff61c6a568f2170eee5a1aa | |
parent | e5e1a4bc916d29958c3b587354293738fcb984d7 (diff) |
tools, bpftool: Avoid array index warnings.
The bpf_caps array is shorter without CAP_BPF, avoid out of bounds reads
if this isn't defined. Working around this avoids -Wno-array-bounds with
clang.
Signed-off-by: Ian Rogers <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
-rw-r--r-- | tools/bpf/bpftool/feature.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/feature.c b/tools/bpf/bpftool/feature.c index a43a6f10b564..359960a8f1de 100644 --- a/tools/bpf/bpftool/feature.c +++ b/tools/bpf/bpftool/feature.c @@ -843,9 +843,14 @@ static int handle_perms(void) else p_err("missing %s%s%s%s%s%s%s%srequired for full feature probing; run as root or use 'unprivileged'", capability_msg(bpf_caps, 0), +#ifdef CAP_BPF capability_msg(bpf_caps, 1), capability_msg(bpf_caps, 2), - capability_msg(bpf_caps, 3)); + capability_msg(bpf_caps, 3) +#else + "", "", "", "", "", "" +#endif /* CAP_BPF */ + ); goto exit_free; } |