Commit 462e5af
committed
posix: c_lib_ext: fnmatch: fix escape-oriented regression
A regression in 936d027 introduced a
subtle bug in the way that escaped expressions were handled.
The regression originated with the assumption that test data (originally
adapted from a 3rd-party testsuite) was correct when it was in fact
flawed.
Specifically, `fnmatch("[[?*\\]", "\\", 0)` should fail, since the "\\"
sequence (a single backslash after compilation) escapes the following ']'
character, thus leaving the bracket expression incomplete. Since the
bracket expression (and therefore the whole pattern) is erroneous, the
call should return `FNM_NOMATCH` to indicate failure rather than 0 to
indicate success.
Added new test cases from #98827 and some commentary for subsequent
reviewers.
This change does not complete #55186 but is related to it.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Signed-off-by: Keith Packard <keithp@keithp.com>1 parent 3cf7b20 commit 462e5af
2 files changed
+23
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 93 | + | |
96 | 94 | | |
97 | 95 | | |
98 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
35 | 55 | | |
36 | 56 | | |
37 | 57 | | |
| |||
0 commit comments