public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpftool: fix a wrong type cast in btf_dumper_int
@ 2022-08-24 22:59 Lam Thai
  2022-08-25  6:29 ` John Fastabend
  2022-08-25 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 6+ messages in thread
From: Lam Thai @ 2022-08-24 22:59 UTC (permalink / raw)
  To: bpf; +Cc: Lam Thai

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: b12d6ec09730 ("bpf: btf: add btf print functionality")
Signed-off-by: Lam Thai <lamthai@arista.com>
---
 tools/bpf/bpftool/btf_dumper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/btf_dumper.c b/tools/bpf/bpftool/btf_dumper.c
index 125798b0bc5d..19924b6ce796 100644
--- a/tools/bpf/bpftool/btf_dumper.c
+++ b/tools/bpf/bpftool/btf_dumper.c
@@ -452,7 +452,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 */

base-commit: 6fc2838b148f8fe6aa14fc435e666984a0505018
-- 
2.37.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-25 18:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-24 22:59 [PATCH] bpftool: fix a wrong type cast in btf_dumper_int Lam Thai
2022-08-25  6:29 ` John Fastabend
2022-08-25  8:56   ` Quentin Monnet
2022-08-25 15:54     ` John Fastabend
2022-08-25 18:44     ` Andrii Nakryiko
2022-08-25 18:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox