diff options
author | Rong Tao <rongtao@cestc.cn> | 2025-08-30 00:31:58 +0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2025-09-09 15:07:58 -0700 |
commit | 7edfc024708258d75f65fadffd7e5f6ac46810b6 (patch) | |
tree | 8160706ca0a305ecd7d1e4fe273f2aa8edd52e4d /scripts/rustdoc_test_builder.rs | |
parent | 387be23a95b14705a804900c3a0db5a12bf19636 (diff) |
bpf: Fix bpf_strnstr() to handle suffix match cases better
bpf_strnstr() should not treat the ending '\0' of s2 as a matching character
if the parameter 'len' equal to s2 string length, for example:
1. bpf_strnstr("openat", "open", 4) = -ENOENT
2. bpf_strnstr("openat", "open", 5) = 0
This patch makes (1) return 0, fix just the `len == strlen(s2)` case.
And fix a more general case when s2 is a suffix of the first len
characters of s1.
Fixes: e91370550f1f ("bpf: Add kfuncs for read-only string operations")
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/tencent_17DC57B9D16BC443837021BEACE84B7C1507@qq.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'scripts/rustdoc_test_builder.rs')
0 files changed, 0 insertions, 0 deletions