提交 8eb62958 编写于 作者: A Andrii Nakryiko 提交者: Daniel Borkmann

libbpf: Fix potential multiplication overflow

Detected by LGTM static analyze in Github repo, fix potential multiplication
overflow before result is casted to size_t.

Fixes: 8505e870 ("libbpf: Implement generalized .BTF.ext func/line info adjustment")
Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200904041611.1695163-2-andriin@fb.com
上级 17e54b09
......@@ -5802,7 +5802,7 @@ static int adjust_prog_btf_ext_info(const struct bpf_object *obj,
/* append func/line info of a given (sub-)program to the main
* program func/line info
*/
old_sz = (*prog_rec_cnt) * ext_info->rec_size;
old_sz = (size_t)(*prog_rec_cnt) * ext_info->rec_size;
new_sz = old_sz + (copy_end - copy_start);
new_prog_info = realloc(*prog_info, new_sz);
if (!new_prog_info)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册