You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
find panics (str char-boundary) on a multibyte char after a malformed bracket class in -name #719
find -name panics on a glob pattern containing a malformed POSIX bracket sub-expression ([., [=, or [:) that is followed by a multibyte UTF-8 character (e.g. '[[:]é'). The bracket parser assumes a fixed 2-byte ASCII closing delimiter and slices the remaining string at an offset that can land inside the next multibyte char. This aborts with a Rust panic (exit code 101). GNU find accepts the same pattern and exits 0.
Steps to reproduce
$ ./target/release/find . -name '[[:]é'thread 'main' panicked at src/find/matchers/glob.rs:87:44:byte index 2 is not a char boundary; it is inside 'é' (bytes 1..3) of `]é`
$ echo$?101
Other patterns that trigger the same panic: '[[:a]é', '[[.]é', '[[:é]'. Reachable via -name/-iname/-path/-ipath/-lname/-ilname (all route through glob::Pattern).
Expected behavior
Match GNU: accept the pattern (treating the malformed bracket text literally) and exit 0 with no error.
$ /usr/bin/find . -name '[[:]é'
$ echo$?0
Root cause
extract_bracket_expr handles a [./[=/[: introducer by searching for the closing delimiter and assuming it is exactly 2 bytes (+ 2):
// src/find/matchers/glob.rs:84ifmatches!(delim,'.' | '=' | ':'){let rest = chars.as_str();let end = rest.find([delim,']'])? + 2;
expr.push_str(&rest[..end]);// line 87: panics if `end` is not a char boundary
chars = rest[end..].chars();}
rest.find([delim, ']']) finds the first occurrence of eitherdelim or ], not the two-byte closing sequence delim]. When only a single delimiter byte is present (e.g. just ] in ]é), find returns that byte's index and the + 2 overshoots into the following character. &rest[..end] then slices off a UTF-8 boundary (end = 2 lands inside é at bytes 1..3) and panics.
Activity