]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, bpftool: fix a few ubsan warnings
authorYonghong Song <yhs@fb.com>
Wed, 10 Apr 2019 00:37:41 +0000 (17:37 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 10 Apr 2019 07:46:51 +0000 (09:46 +0200)
commit176662a3e8ae9ba55e17057602b8820adcdddd70
tree75665c934bb3b1449a290394d33f2b435d16b6f9
parent67c9d3da54b8d2c7a8228cbf977520db2581c523
bpf, bpftool: fix a few ubsan warnings

The issue is reported at https://github.com/libbpf/libbpf/issues/28.

Basically, per C standard, for
  void *memcpy(void *dest, const void *src, size_t n)
if "dest" or "src" is NULL, regardless of whether "n" is 0 or not,
the result of memcpy is undefined. clang ubsan reported three such
instances in bpf.c with the following pattern:
  memcpy(dest, 0, 0).

Although in practice, no known compiler will cause issues when
copy size is 0. Let us still fix the issue to silence ubsan
warnings.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/bpf.c