find: reject invalid UTF-8 in --files0-from - #798
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
Commit 328bb5f has test result changes: bfs testsuite: |
| #[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)?)) | ||
| } | ||
|
|
There was a problem hiding this comment.
i don't think it is an interesting test
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
i am not a fan of answering to an LLM in a comment... esp when it adds 0 value :(
328bb5f to
b6ac791
Compare
|
Commit b6ac791 has test result changes: bfs testsuite: |
Fixes #781.
--files0-fromdecoded 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.