Skip to content

find: -name: don't panic on a malformed POSIX bracket class - #722

Merged
sylvestre merged 1 commit into
uutils:mainfrom
leeewee:find-fix-name-glob-bracket
Jun 9, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
leeewee:find-fix-name-glob-bracket

Conversation

@leeewee

@leeewee leeewee commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #719

find -name panicked (exit 101) on a glob with a [./[=/[: introducer whose closing delimiter is missing — a lone ] (or the delimiter) before a multibyte char, e.g. '[[:]é'. extract_bracket_expr searched for either the delimiter or ] and then added a blind + 2, which overshot into the following character and sliced off a UTF-8 boundary.

Search for the actual two-byte closing sequence <delim>] instead. A valid class ([:alpha:]) is unchanged; a malformed one returns None, so the caller treats [ literally and accepts the pattern like GNU find (exit 0). Reachable via -name/-iname/-path/-ipath/-lname/-ilname. Adds a regression test.

A `-name` glob with a `[.`/`[=`/`[:` introducer whose closing delimiter is
missing — only a lone `]` (or the delimiter) before a multibyte char, e.g.
`'[[:]é'` — panicked (exit 101). `extract_bracket_expr` searched for *either*
the delimiter or `]` and then added a blind `+ 2`, which overshot into the
following character and sliced off a UTF-8 boundary.

Search for the actual two-byte closing sequence `<delim>]` instead. A valid
class (`[:alpha:]`) is unchanged; a malformed one returns None, so the caller
treats `[` literally and accepts the pattern like GNU find (exit 0). Reachable
via -name/-iname/-path/-ipath/-lname/-ilname. Adds a regression test.
@codspeed

codspeed Bot commented Jun 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing leeewee:find-fix-name-glob-bracket (22c57f3) with main (865ab09)

Open in CodSpeed

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.84%. Comparing base (62deaf6) to head (22c57f3).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #722   +/-   ##
=======================================
  Coverage   91.83%   91.84%           
=======================================
  Files          35       35           
  Lines        7129     7135    +6     
  Branches      375      375           
=======================================
+ Hits         6547     6553    +6     
  Misses        437      437           
  Partials      145      145           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sylvestre
sylvestre merged commit 001966f into uutils:main Jun 9, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

find panics (str char-boundary) on a multibyte char after a malformed bracket class in -name

2 participants