xref: /linux/tools/testing/selftests/bpf/progs/test_snprintf_single.c (revision 9dbbc3b9d09d6deba9f3b9e1d5b355032ed46a75)
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")
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