Skip to content

Commit

Permalink
bpftool: Fix a wrong type cast in btf_dumper_int
Browse files Browse the repository at this point in the history
[ Upstream commit 7184aef9c0f7a81db8fd18d183ee42481d89bf35 ]

When `data` points to a boolean value, casting it to `int *` is problematic
and could lead to a wrong value being passed to `jsonw_bool`. Change the
cast to `bool *` instead.

Fixes: b12d6ec ("bpf: btf: add btf print functionality")
Signed-off-by: Lam Thai <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Reviewed-by: Quentin Monnet <[email protected]>
Acked-by: John Fastabend <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
lam-arista authored and techyminati committed Mar 28, 2024
1 parent 1de7c7b commit 7b460ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/bpf/bpftool/btf_dumper.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static int btf_dumper_int(const struct btf_type *t, __u8 bit_offset,
*(char *)data);
break;
case BTF_INT_BOOL:
jsonw_bool(jw, *(int *)data);
jsonw_bool(jw, *(bool *)data);
break;
default:
/* shouldn't happen */
Expand Down

0 comments on commit 7b460ae

Please sign in to comment.