find: avoid panic on a non-UTF-8 argument - #833
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #833 +/- ##
==========================================
+ Coverage 92.15% 92.17% +0.01%
==========================================
Files 35 35
Lines 7377 7395 +18
Branches 383 383
==========================================
+ Hits 6798 6816 +18
Misses 438 438
Partials 141 141 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 2e69802 has test result changes: bfs testsuite: |
Contributor
|
please add a test_find.rs |
AlejandroCoronadoN
force-pushed
the
fix-find-non-utf8-args
branch
from
August 17, 2026 14:18
2e69802 to
977aa58
Compare
Contributor
Author
|
Done, added an integration test in test_find.rs that passes a non-UTF-8 argument and checks it errors cleanly instead of panicking. |
|
Commit 977aa58 has test result changes: bfs testsuite: |
std::env::args panics on a non-UTF-8 argument. Read the arguments with args_os and report the first invalid one with a clean error and exit 1, instead of aborting (uutils#816). Adds a helper unit test and a test_find.rs test.
sylvestre
force-pushed
the
fix-find-non-utf8-args
branch
from
August 18, 2026 17:22
977aa58 to
5103940
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A non-UTF-8 argument makes
findpanic during argument collection, before the formatparser is ever reached:
Root cause
maincollected arguments withstd::env::args(), which panics on a non-UTF-8 argument.Fix
Collect with
std::env::args_os()and report the first non-UTF-8 argument as an error,exiting with code 1 instead of aborting. The conversion is extracted into a small
collect_utf8_argshelper so it can be unit-tested. Full GNU-style byte pass-through ofthe format string is a larger change and left as a follow-up.
Verification
Adds unit tests
collects_valid_utf8_argsandnon_utf8_arg_is_rejected_not_panicking.cargo fmtandcargo clippy --bin findare clean.Fixes #816.