find: reject a signed -maxdepth/-mindepth value to match GNU - #835
Open
AlejandroCoronadoN wants to merge 1 commit into
Open
find: reject a signed -maxdepth/-mindepth value to match GNU#835AlejandroCoronadoN wants to merge 1 commit into
AlejandroCoronadoN wants to merge 1 commit into
Conversation
convert_arg_to_number parsed the depth with Rust's usize parser, which accepts a leading '+', so "-maxdepth +1" was silently accepted. GNU find rejects a signed value there, which is also what this function's own "positive decimal integer" error message implies. Only accept plain decimal digits.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #835 +/- ##
==========================================
+ Coverage 91.93% 91.99% +0.06%
==========================================
Files 35 35
Lines 7253 7261 +8
Branches 378 378
==========================================
+ Hits 6668 6680 +12
+ Misses 443 439 -4
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 2c18ead has test result changes: GNU findutils testsuite: 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.
Problem
-maxdepth/-mindepthaccepted a+-signed value that GNU rejects:Rust's
usize::from_straccepts a leading+, soconvert_arg_to_numberletit through, which is inconsistent with the function's own "positive decimal
integer" error message.
Fix
Only accept plain decimal digits.
Verification
Compared against GNU findutils (
gfind) for-maxdepthand-mindepthover1,+1,-1,+2,0,2; exit codes match in every case. Added a unittest;
cargo test --libpasses andcargo fmt/cargo clippyare clean.