[PATCH 3/6] renice: disallow --priority <arg> without pid argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Earlier a lonely priority with an argument but without pid resulted to no
action and success, when the invocation should have failed.

$ renice --priority 42 ; echo $?
0

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 sys-utils/renice.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys-utils/renice.c b/sys-utils/renice.c
index 0605680..2075d40 100644
--- a/sys-utils/renice.c
+++ b/sys-utils/renice.c
@@ -131,14 +131,14 @@ main(int argc, char **argv)
 		}
 	}
 
-	if (argc < 2)
-		usage(stderr);
-
-	if (strcmp(*argv, "-n") == 0 || strcmp(*argv, "--priority") == 0) {
+	if (*argv && (strcmp(*argv, "-n") == 0 || strcmp(*argv, "--priority") == 0)) {
 		argc--;
 		argv++;
 	}
 
+	if (argc < 2)
+		usage(stderr);
+
 	prio = strtol(*argv, &endptr, 10);
 	if (*endptr)
 		usage(stderr);
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux