]> granicus.if.org Git - procps-ng/commitdiff
skill: Always NULL-terminate argv.
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Fri, 18 May 2018 21:32:21 +0000 (07:32 +1000)
The memmove() itself does not move the NULL-terminator, because nargs is
decremented first. Copy how skill_sig_option() does it: decrement nargs
last, and remove the "if (nargs - i)" (we are in "while (i < nargs)").

skill.c

diff --git a/skill.c b/skill.c
index 40ec787da17ade685138a6382286bee8fa0ef70e..33af11e4806c44bd80761fdef98752a829aa5b08 100644 (file)
--- a/skill.c
+++ b/skill.c
@@ -542,10 +542,9 @@ static int snice_prio_option(int *argc, char **argv)
                        if (prio < INT_MIN || INT_MAX < prio)
                                xerrx(EXIT_FAILURE,
                                     _("priority %lu out of range"), prio);
+                       memmove(argv + i, argv + i + 1,
+                               sizeof(char *) * (nargs - i));
                        nargs--;
-                       if (nargs - i)
-                               memmove(argv + i, argv + i + 1,
-                                       sizeof(char *) * (nargs - i));
                } else
                        i++;
        }