aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2025-07-01 21:48:03 +0200
committerAlexei Starovoitov <ast@kernel.org>2025-07-01 15:22:46 -0700
commitbf4807c89d8f92c47404b1e4eeeefb42259d1b50 (patch)
tree05420dd3623b9445124ae1fabf8446c47c35b9ca
parentbpf: Reject %p% format string in bprintf-like helpers (diff)
downloadwireguard-linux-bf4807c89d8f92c47404b1e4eeeefb42259d1b50.tar.xz
wireguard-linux-bf4807c89d8f92c47404b1e4eeeefb42259d1b50.zip
selftests/bpf: Add negative test cases for snprintf
This patch adds a couple negative test cases with a trailing % at the end of the format string. The %p% case was fixed by the previous commit, whereas the %s% case was already successfully rejected before. Acked-by: Yonghong Song <yonghong.song@linux.dev> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com> Link: https://lore.kernel.org/r/0669bf6eb4f9e5bb10e949d60311c06e2d942447.1751395489.git.paul.chaignon@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r--tools/testing/selftests/bpf/prog_tests/snprintf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/snprintf.c b/tools/testing/selftests/bpf/prog_tests/snprintf.c
index 4be6fdb78c6a..594441acb707 100644
--- a/tools/testing/selftests/bpf/prog_tests/snprintf.c
+++ b/tools/testing/selftests/bpf/prog_tests/snprintf.c
@@ -116,6 +116,8 @@ static void test_snprintf_negative(void)
ASSERT_ERR(load_single_snprintf("%llc"), "invalid specifier 7");
ASSERT_ERR(load_single_snprintf("\x80"), "non ascii character");
ASSERT_ERR(load_single_snprintf("\x1"), "non printable character");
+ ASSERT_ERR(load_single_snprintf("%p%"), "invalid specifier 8");
+ ASSERT_ERR(load_single_snprintf("%s%"), "invalid specifier 9");
}
void test_snprintf(void)