xref: /linux/tools/testing/selftests/bpf/progs/test_snprintf_single.c (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Google LLC. */
3 
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 
7 /* The format string is filled from the userspace such that loading fails */
8 const char fmt[10];
9 
10 SEC("raw_tp/sys_enter")
handler(const void * ctx)11 int handler(const void *ctx)
12 {
13 	unsigned long long arg = 42;
14 
15 	bpf_snprintf(NULL, 0, fmt, &arg, sizeof(arg));
16 
17 	return 0;
18 }
19 
20 char _license[] SEC("license") = "GPL";
21