mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 21:03:32 +00:00
selftests/bpf: fix a test for snprintf() overflow
The snprintf() function returns the number of bytes which *would*
have been copied if there were space. In other words, it can be
> sizeof(pin_path).
Fixes: c0fa1b6c3e
("bpf: btf: Add BTF tests")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/r/YtZ+aD/tZMkgOUw+@kili
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
979855d302
commit
c5d22f4cfe
1 changed files with 1 additions and 1 deletions
|
@ -5338,7 +5338,7 @@ static void do_test_pprint(int test_num)
|
||||||
ret = snprintf(pin_path, sizeof(pin_path), "%s/%s",
|
ret = snprintf(pin_path, sizeof(pin_path), "%s/%s",
|
||||||
"/sys/fs/bpf", test->map_name);
|
"/sys/fs/bpf", test->map_name);
|
||||||
|
|
||||||
if (CHECK(ret == sizeof(pin_path), "pin_path %s/%s is too long",
|
if (CHECK(ret >= sizeof(pin_path), "pin_path %s/%s is too long",
|
||||||
"/sys/fs/bpf", test->map_name)) {
|
"/sys/fs/bpf", test->map_name)) {
|
||||||
err = -1;
|
err = -1;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Reference in a new issue