Skip to content

xargs: cap the default command line size at 128 KiB - #791

Merged
sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:xargs-default-cmdline-cap
Jul 26, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
sylvestre:xargs-default-cmdline-cap

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Sizing command lines all the way up to ARG_MAX made execvp() fail with E2BIG: the kernel also charges the argv/envp pointer arrays against the limit, which the character count does not account for. Follow GNU xargs and use at most 128 KiB per command line by default, and use a saturating subtraction so a tiny ARG_MAX cannot underflow.

The cap only applies when no explicit -s was given: like GNU, an explicit -s may still raise the limit up to the system maximum.

Sizing command lines all the way up to ARG_MAX made execvp() fail with
E2BIG: the kernel also charges the argv/envp pointer arrays against the
limit, which the character count does not account for. Follow GNU xargs
and use at most 128 KiB per command line by default, and use a
saturating subtraction so a tiny ARG_MAX cannot underflow.

The cap only applies when no explicit -s was given: like GNU, an
explicit -s may still raise the limit up to the system maximum.
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.90%. Comparing base (f41011c) to head (d1dd396).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #791      +/-   ##
==========================================
+ Coverage   91.88%   91.90%   +0.01%     
==========================================
  Files          35       35              
  Lines        7159     7174      +15     
  Branches      376      376              
==========================================
+ Hits         6578     6593      +15     
  Misses        437      437              
  Partials      144      144              

☔ 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.

@codspeed

codspeed Bot commented Jul 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing sylvestre:xargs-default-cmdline-cap (d1dd396) with main (f41011c)

Open in CodSpeed

@github-actions

Copy link
Copy Markdown

Commit d1dd396 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 312 / PASSED: 266 / FAILED: 40 / SKIPPED: 6
  Reference: TOTAL: 314 / PASSED: 266 / FAILED: 42 / SKIPPED: 6

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

Test improvements (2):
  + gnu/files0_from_ok
  + gnu/okdir_path_empty

@sylvestre
sylvestre merged commit bf3af48 into uutils:main Jul 26, 2026
22 checks passed
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