Page MenuHomeFreeBSD

xargs: Prevent overflow in linelen calculation if nargs is large.
ClosedPublic

Authored by des on Jul 13 2023, 7:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 2, 12:48 PM
Unknown Object (File)
Thu, May 2, 12:48 PM
Unknown Object (File)
Thu, May 2, 11:08 AM
Unknown Object (File)
Thu, May 2, 10:38 AM
Unknown Object (File)
Fri, Apr 26, 1:10 AM
Unknown Object (File)
Sat, Apr 20, 4:00 AM
Unknown Object (File)
Apr 4 2024, 9:03 AM
Unknown Object (File)
Mar 31 2024, 8:45 PM

Details

Summary

MFC after: 1 week
Sponsored by: Klara, Inc.

Diff Detail

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

Event Timeline

des requested review of this revision.Jul 13 2023, 7:59 PM
This revision is now accepted and ready to land.Jul 13 2023, 8:03 PM

Nice catch! Thank you!
Just a few minor suggestions in the tests.

usr.bin/xargs/tests/regress.n2147483647.out
2

This file needs to be included in usr.bin/xargs/tests/Makefile

usr.bin/xargs/tests/regress.sh
3

This needs to be bumped (+1).

For some reason this patch is not working for me, It works fine on macOS. I'll take a closer look later.

usr.bin/xargs/xargs.c
261

@des, sorry to insist, but I had to malloc -> calloc in order to get your test passing. Maybe I'm missing something here.

I reverted the addition of the regression test since it triggers OOM kills in ci.freebsd.org and in my local testing environment. The problem is that the test triggers an allocation of 16GB when jemalloc debugging is enabled, and most environments don't have that much RAM available.

Is there any need to allow values for -n larger than ARG_MAX?