Page MenuHomeFreeBSD

xargs: Limit -n to {ARG_MAX}
ClosedPublic

Authored by des on Fri, Jul 25, 6:58 PM.
Tags
None
Referenced Files
F125438122: D51536.diff
Thu, Aug 7, 7:20 PM
F125438121: D51536.diff
Thu, Aug 7, 7:20 PM
Unknown Object (File)
Mon, Jul 28, 6:40 PM
Unknown Object (File)
Mon, Jul 28, 5:01 PM
Unknown Object (File)
Mon, Jul 28, 6:31 AM
Unknown Object (File)
Mon, Jul 28, 6:29 AM
Unknown Object (File)
Sun, Jul 27, 10:35 PM
Unknown Object (File)
Sun, Jul 27, 9:14 PM
Subscribers

Details

Summary

Since it's not possible to pass more than {ARG_MAX} bytes on the command
line, it's also not possible to pass more than {ARG_MAX} individual
arguments. Therefore, {ARG_MAX} is a reasonable upper bound for the -n
option. This resolves both the arithmetic overflow issue and the CI OOM
issue, so we can safely re-enable the test.

Fixes: eab91d008165
Fixes: 2682a1552724
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Fri, Jul 25, 6:58 PM

seems reasonable

usr.bin/xargs/tests/regress.sh
15–16

since the filename is fixed as n524288.out anyway it seems using $(()) is an unnecessary minor obfuscation

This revision is now accepted and ready to land.Fri, Jul 25, 7:24 PM
des marked an inline comment as done.Fri, Jul 25, 7:26 PM
des added inline comments.
usr.bin/xargs/tests/regress.sh
15–16

it gets dropped in D51537

des marked an inline comment as done.Fri, Jul 25, 7:28 PM
des added inline comments.
usr.bin/xargs/tests/regress.sh
15–16

the reason for it btw is that's how ARG_MAX is defined in sys/sys/syslimits.h:

#define	ARG_MAX	      (2 * 256 * 1024)	/* max bytes for an exec function */

Thank you! Seems reasonable.

{ARG_MAX} is variable, don't hardcode it

This revision now requires review to proceed.Fri, Jul 25, 7:53 PM
This revision is now accepted and ready to land.Fri, Jul 25, 7:58 PM
This revision was automatically updated to reflect the committed changes.