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)
Mon, Oct 21, 3:19 AM
Unknown Object (File)
Oct 1 2024, 1:45 PM
Unknown Object (File)
Oct 1 2024, 1:43 PM
Unknown Object (File)
Oct 1 2024, 11:29 AM
Unknown Object (File)
Sep 28 2024, 1:18 PM
Unknown Object (File)
Sep 28 2024, 1:18 PM
Unknown Object (File)
Sep 28 2024, 1:18 PM
Unknown Object (File)
Sep 28 2024, 1:07 PM
Subscribers

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?