Commit 0715f71
bpf/helpers: bpf_strnstr: Exact match length
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: e913705 ("bpf: Add kfuncs for read-only string operations")
Signed-off-by: Rong Tao <[email protected]>1 parent 27199db commit 0715f71
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3672 | 3672 | | |
3673 | 3673 | | |
3674 | 3674 | | |
3675 | | - | |
| 3675 | + | |
3676 | 3676 | | |
3677 | 3677 | | |
3678 | 3678 | | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
3679 | 3686 | | |
3680 | 3687 | | |
3681 | 3688 | | |
| |||
0 commit comments