Skip to content

Commit bf4807c

Browse files
pchaignoAlexei Starovoitov
authored andcommitted
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>
1 parent f824274 commit bf4807c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

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)