Skip to content

Commit 0e1acf6

Browse files
committed
selftests/bpf: Add negative test cases for snprintf
JIRA: https://issues.redhat.com/browse/RHEL-110274 commit bf4807c Author: Paul Chaignon <paul.chaignon@gmail.com> Date: Tue Jul 1 21:48:03 2025 +0200 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> Signed-off-by: Viktor Malik <vmalik@redhat.com>
1 parent a716d6c commit 0e1acf6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/bpf/prog_tests/snprintf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ static void test_snprintf_negative(void)
116116
ASSERT_ERR(load_single_snprintf("%llc"), "invalid specifier 7");
117117
ASSERT_ERR(load_single_snprintf("\x80"), "non ascii character");
118118
ASSERT_ERR(load_single_snprintf("\x1"), "non printable character");
119+
ASSERT_ERR(load_single_snprintf("%p%"), "invalid specifier 8");
120+
ASSERT_ERR(load_single_snprintf("%s%"), "invalid specifier 9");
119121
}
120122

121123
void test_snprintf(void)

0 commit comments

Comments
 (0)