summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2018-09-13 22:00:11 +0000
committerRobert Mustacchi <rm@joyent.com>2019-01-16 18:55:22 +0000
commit7c71d71894ca896e2718a24b51b39b0e5f9c27e6 (patch)
tree27da9debce08eacc1f1f68676564ddcd5a8003dc /usr/src/cmd
parent1bf8e91c2f089f0b4e9a6f705f162654aa82cfad (diff)
downloadillumos-gate-7c71d71894ca896e2718a24b51b39b0e5f9c27e6.tar.gz
10216 xargs does not properly detect when -P is negative
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Andy Fiddaman <af@citrus-it.net> Reviewed by: Andy Stormont <astormont@racktopsystems.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/xargs/xargs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr/src/cmd/xargs/xargs.c b/usr/src/cmd/xargs/xargs.c
index 517c33c7e1..26feb9bdf6 100644
--- a/usr/src/cmd/xargs/xargs.c
+++ b/usr/src/cmd/xargs/xargs.c
@@ -21,7 +21,7 @@
/*
* Copyright 2014 Garrett D'Amore <garrett@damore.org>
* Copyright 2012 DEY Storage Systems, Inc.
- * Copyright (c) 2017, Joyent, Inc.
+ * Copyright (c) 2018, Joyent, Inc.
*
* Portions of this file developed by DEY Storage Systems, Inc. are licensed
* under the terms of the Common Development and Distribution License (CDDL)
@@ -163,7 +163,7 @@ int
main(int argc, char **argv)
{
int j;
- unsigned long l;
+ long l;
struct inserts *psave;
int c;
int initsize;
@@ -316,13 +316,19 @@ main(int argc, char **argv)
case 'P': /* -P maxprocs: # of child processses */
errno = 0;
- l = strtoul(optarg, &eptr, 10);
+ l = strtol(optarg, &eptr, 10);
if (*eptr != '\0' || errno != 0) {
ermsg(_("failed to parse maxprocs (-P): %s\n"),
optarg);
break;
}
+ if (l < 0) {
+ ermsg(_("maximum number of processes (-P) "
+ "cannot be negative\n"));
+ break;
+ }
+
/*
* Come up with an upper bound that'll probably fit in
* memory.