Skip to content

find: reject a signed -maxdepth/-mindepth value to match GNU - #835

Open
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-maxdepth-signed
Open

find: reject a signed -maxdepth/-mindepth value to match GNU#835
AlejandroCoronadoN wants to merge 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-maxdepth-signed

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown

Problem

-maxdepth/-mindepth accepted a +-signed value that GNU rejects:

$ find dir -maxdepth +1     # uutils: runs normally (parsed as 1)
$ gfind dir -maxdepth +1
find: Expected a positive decimal integer argument to -maxdepth, but got '+1'

Rust's usize::from_str accepts a leading +, so convert_arg_to_number let
it 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 -maxdepth and -mindepth over
1, +1, -1, +2, 0, 2; exit codes match in every case. Added a unit
test; cargo test --lib passes and cargo fmt / cargo clippy are clean.

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.
@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing AlejandroCoronadoN:fix-maxdepth-signed (2c18ead) with main (5aa8184)

Open in CodSpeed

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.99%. Comparing base (5aa8184) to head (2c18ead).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Commit 2c18ead has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 421 / FAILED: 73 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 417 / FAILED: 77 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +4
  FAILED: -4

Test improvements (4):
  + mindepth-badarg.new-O0
  + mindepth-badarg.new-O1
  + mindepth-badarg.new-O2
  + mindepth-badarg.new-O3

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 267 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +0
  PASSED: -1
  FAILED: +1

New test failures (1):
  - gnu/files0_from_ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant