tools: bpf: make use of reallocarray
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 10 Jul 2018 21:43:05 +0000 (14:43 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 11 Jul 2018 20:13:34 +0000 (22:13 +0200)
commit531b014e7a2fedaeff0b19b2934d830cd4b35dc0
tree0de8355e9d533b4f6f90c3b389f58c992e75bb14
parent8d13406c02f9c38f106416e1dbe0e68059b9f59a
tools: bpf: make use of reallocarray

reallocarray() is a safer variant of realloc which checks for
multiplication overflow in case of array allocation.  Since it's
not available in Glibc < 2.26 import kernel's overflow.h and
add a static inline implementation when needed.  Use feature
detection to probe for existence of reallocarray.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jiong Wang <jiong.wang@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/Makefile
tools/bpf/bpftool/main.h
tools/bpf/bpftool/xlated_dumper.c
tools/build/feature/Makefile
tools/build/feature/test-reallocarray.c [new file with mode: 0644]
tools/include/linux/compiler-gcc.h
tools/include/linux/overflow.h [new file with mode: 0644]
tools/include/tools/libc_compat.h [new file with mode: 0644]
tools/lib/bpf/Makefile
tools/lib/bpf/libbpf.c