]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
renice: disallow --priority <arg> without pid argument
authorSami Kerola <kerolasa@iki.fi>
Fri, 5 Sep 2014 22:17:19 +0000 (23:17 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Sep 2014 18:31:12 +0000 (19:31 +0100)
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@iki.fi>
sys-utils/renice.c

index 06056802b18726403a77e260ffd1bd26a59f2600..2075d407622fcdb86c1ead3dfe74e9774fbd5d18 100644 (file)
@@ -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);