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