Repository navigation
find: reject a non-numeric prefix in the -size argument - #834
Merged
sylvestre merged 1 commit intoAug 18, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #834 +/- ##
==========================================
+ Coverage 92.01% 92.09% +0.08%
==========================================
Files 35 35
Lines 7316 7316
Branches 378 378
==========================================
+ Hits 6732 6738 +6
+ Misses 442 437 -5
+ Partials 142 141 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit 7b24ce6 has test result changes: GNU findutils testsuite: bfs testsuite: |
Contributor
|
please add a test_find.rs |
The -size argument was parsed with an un-anchored regex, so "x5c" or "abc5c" silently matched the "5c" in the middle. Anchor the regex and allow only the one extra '+' GNU accepts after the comparison sign, so "++5c"/"-+5c" stay valid while the junk-prefix and invalid-sign forms are rejected. Adds a test_find.rs test.
AlejandroCoronadoN
force-pushed
the
fix-size-nonnumeric-prefix
branch
from
August 17, 2026 14:13
7b24ce6 to
5b798e1
Compare
Contributor
Author
|
Done, added an integration test in test_find.rs covering the rejected and accepted -size forms. |
|
Commit 5b798e1 has test result changes: GNU findutils testsuite: bfs testsuite: |
1 task done
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
find's-sizeargument was parsed with an un-anchored regex(
([-+]?)[-+]?(\d+)(.*)$), so a non-numeric prefix was silently accepted:GNU
findrejects these withfind: Invalid argument 'x5c' to -size. The extrasign group also accepted
+-5cand--5c, which GNU rejects too.Fix
Anchor the regex at the start and replace the second
[-+]?with\+?, whichmatches GNU's grammar exactly: after the comparison sign GNU accepts one more
optional
+(so++5cand-+5care valid), but not a second-.Verification
Compared against GNU findutils (
gfind) over 13-sizeinputs; exit codes andthe matched file sets are identical:
x5c,abc5c+-5c,--5c,+++5c5c,+5c,-5c,++5c,-+5c-mtime/-inumnumeric parsing is unchanged. Added a unit test; the fullcargo test --libsuite (227 tests) passes andcargo fmt/cargo clippyareclean.