Skip to content

find: reject invalid UTF-8 in --files0-from - #798

Merged
sylvestre merged 1 commit into
uutils:mainfrom
wtcpython:fix/find-files0-non-utf8
Jul 28, 2026
Merged

find: reject invalid UTF-8 in --files0-from#798
sylvestre merged 1 commit into
uutils:mainfrom
wtcpython:fix/find-files0-non-utf8

Conversation

@wtcpython

@wtcpython wtcpython commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #781.

--files0-from decoded each NUL-separated starting point as UTF-8 and silently discarded segments that were not valid UTF-8. As a result, non-UTF-8 input could produce no traversal and a successful exit status.

Propagate UTF-8 decoding errors instead of silently ignoring invalid starting points.

Add a regression test using the issue's non-UTF-8 input and verify that it fails without producing output.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.90%. Comparing base (2d020a3) to head (b6ac791).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #798      +/-   ##
==========================================
- Coverage   91.90%   91.90%   -0.01%     
==========================================
  Files          35       35              
  Lines        7249     7248       -1     
  Branches      376      376              
==========================================
- Hits         6662     6661       -1     
  Misses        444      444              
  Partials      143      143              

☔ 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.

@github-actions

Copy link
Copy Markdown

Commit 328bb5f has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 265 / FAILED: 43 / SKIPPED: 6
  Reference: TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: +0
  PASSED: -2
  FAILED: +2

New test failures (2):
  - gnu/okdir_path_empty
  - gnu/okdir_path_relative

@codspeed-hq

codspeed-hq Bot commented Jul 28, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing wtcpython:fix/find-files0-non-utf8 (b6ac791) with main (2d020a3)

Open in CodSpeed

Comment thread src/find/matchers/mod.rs Outdated
Comment on lines +1063 to +1075
#[cfg(unix)]
fn path_from_bytes(bytes: &[u8]) -> PathBuf {
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;

PathBuf::from(OsString::from_vec(bytes.to_vec()))
}

#[cfg(not(unix))]
fn path_from_bytes(bytes: &[u8]) -> Result<PathBuf, Box<dyn Error>> {
Ok(PathBuf::from(std::str::from_utf8(bytes)?))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it is an interesting test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry — I over-scoped the fix by adding native-path handling beyond what the issue requires. I've simplified it to propagate the UTF-8 decoding error, removing the PathBuf refactor and both platform-specific helpers. The PR is now limited to the parser change and its regression test. Thanks for pointing this out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not a fan of answering to an LLM in a comment... esp when it adds 0 value :(

@wtcpython
wtcpython force-pushed the fix/find-files0-non-utf8 branch from 328bb5f to b6ac791 Compare July 28, 2026 08:14
@wtcpython wtcpython changed the title find: preserve non-UTF-8 paths from --files0-from find: reject invalid UTF-8 in --files0-from Jul 28, 2026
@github-actions

Copy link
Copy Markdown

Commit b6ac791 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 315 / PASSED: 267 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +0
  FAILED: +1

New test failures (1):
  - gnu/okdir_path_empty

@sylvestre
sylvestre merged commit 3072c3f into uutils:main Jul 28, 2026
22 of 23 checks passed
@wtcpython
wtcpython deleted the fix/find-files0-non-utf8 branch July 28, 2026 10:20
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.

bug(find): not error out when the --files0-from is invalid UTF8 like \xFF

2 participants