summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/testing_helpers.c
diff options
context:
space:
mode:
authorYuntao Wang <ytcoode@gmail.com>2022-04-06 03:36:22 +0300
committerAndrii Nakryiko <andrii@kernel.org>2022-04-06 20:10:03 +0300
commit958ddfd75d83d83e713027677c8786781e1f4576 (patch)
tree5aec89f5bfe8c861da3360b9353dede2a3e5cbc1 /tools/testing/selftests/bpf/testing_helpers.c
parent1963c740dc2b52f45ba3d3748a50a0ab35db098a (diff)
downloadlinux-958ddfd75d83d83e713027677c8786781e1f4576.tar.xz
selftests/bpf: Fix issues in parse_num_list()
The function does not check that parsing_end is false after parsing argument. Thus, if the final part of the argument is something like '4-', which is invalid, parse_num_list() will discard it instead of returning -EINVAL. Before: $ ./test_progs -n 2,4- #2 atomic_bounds:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED After: $ ./test_progs -n 2,4- Failed to parse test numbers. Signed-off-by: Yuntao Wang <ytcoode@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220406003622.73539-1-ytcoode@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/testing_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/testing_helpers.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c
index 795b6798ccee..87867f7a78c3 100644
--- a/tools/testing/selftests/bpf/testing_helpers.c
+++ b/tools/testing/selftests/bpf/testing_helpers.c
@@ -60,7 +60,7 @@ int parse_num_list(const char *s, bool **num_set, int *num_set_len)
set[i] = true;
}
- if (!set)
+ if (!set || parsing_end)
return -EINVAL;
*num_set = set;