libbpf: Deal with section with no data gracefully
authorShung-Hsi Yu <shung-hsi.yu@suse.com>
Wed, 12 Oct 2022 02:23:52 +0000 (10:23 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 13 Oct 2022 17:53:34 +0000 (10:53 -0700)
commit35a855509e6ee3442477c8ebc6827b5b5d32a7b5
tree0008da47b5d124d2ae4f7a6fca5bd01c9dcc0af2
parent51deedc9b8680953437dfe359e5268120de10e30
libbpf: Deal with section with no data gracefully

ELF section data pointer returned by libelf may be NULL (if section has
SHT_NOBITS), so null check section data pointer before attempting to
copy license and kversion section.

Fixes: cb1e5e961991 ("bpf tools: Collect version and license from ELF sections")
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221012022353.7350-3-shung-hsi.yu@suse.com
tools/lib/bpf/libbpf.c