libbpf: Fix potential overflow issue
authorAndrii Nakryiko <andriin@fb.com>
Thu, 7 Nov 2019 02:08:52 +0000 (18:08 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 7 Nov 2019 15:20:37 +0000 (16:20 +0100)
Fix a potential overflow issue found by LGTM analysis, based on Github libbpf
source code.

Fixes: 3d65014146c6 ("bpf: libbpf: Add btf_line_info support to libbpf")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20191107020855.3834758-3-andriin@fb.com
tools/lib/bpf/bpf.c

index ca0d635..b3e3e99 100644 (file)
@@ -189,7 +189,7 @@ static void *
 alloc_zero_tailing_info(const void *orecord, __u32 cnt,
                        __u32 actual_rec_size, __u32 expected_rec_size)
 {
-       __u64 info_len = actual_rec_size * cnt;
+       __u64 info_len = (__u64)actual_rec_size * cnt;
        void *info, *nrecord;
        int i;