git: 1048a870e3b6 - main - xargs: disallow -R0 and -L0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 13 Jul 2023 21:37:25 UTC
The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=1048a870e3b6973a5be1193f3b45e6e867e8e1c0 commit 1048a870e3b6973a5be1193f3b45e6e867e8e1c0 Author: Daniel Tameling <tamelingdaniel@gmail.com> AuthorDate: 2023-07-13 20:06:31 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2023-07-13 21:35:23 +0000 xargs: disallow -R0 and -L0 Both cases were interpreted as these flags are unset. This meant that -R0 got converted to -R5 and that -L0 didn't have any effect at all. Since make at most 0 replacements isn't useful and since call utility for every 0 lines read doesn't make sense, throw an error for these two cases. MFC after: 1 week Reviewed by: des, kevans Differential Revision: https://reviews.freebsd.org/D41022 --- usr.bin/xargs/xargs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 94a32d04fd67..e6f8619bb8d1 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -174,7 +174,7 @@ main(int argc, char *argv[]) replstr = optarg; break; case 'L': - Lflag = (int)strtonum(optarg, 0, INT_MAX, &errstr); + Lflag = (int)strtonum(optarg, 1, INT_MAX, &errstr); if (errstr) errx(1, "-%c %s: %s", ch, optarg, errstr); break; @@ -203,6 +203,8 @@ main(int argc, char *argv[]) Rflag = (int)strtonum(optarg, INT_MIN, INT_MAX, &errstr); if (errstr) errx(1, "-%c %s: %s", ch, optarg, errstr); + if (!Rflag) + errx(1, "-%c %s: %s", ch, optarg, "must be non-zero"); break; case 'r': /* GNU compatibility */