find: avoid panic on a non-UTF-8 argument - #833
Open
AlejandroCoronadoN wants to merge 1 commit into
Open
Conversation
main collected args with std::env::args(), which panics on a non-UTF-8 argument (e.g. ). Collect with args_os and report the first invalid argument as an error, exiting 1 instead of aborting. Adds unit tests for the extracted helper. Fixes uutils#816.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #833 +/- ##
==========================================
- Coverage 91.93% 91.89% -0.04%
==========================================
Files 35 35
Lines 7253 7271 +18
Branches 378 378
==========================================
+ Hits 6668 6682 +14
- Misses 443 447 +4
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 2e69802 has test result changes: bfs testsuite: |
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.