kill: fix segfault in arguments parsing
Signed-off-by: Alexey Fomenko <ext-alexey.fomenko@nokia.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
83f103b30e
commit
6a93212b54
@ -165,13 +165,15 @@ int kill_main(int argc, char **argv)
|
|||||||
/* Stop all processes */
|
/* Stop all processes */
|
||||||
kill(-1, SIGSTOP);
|
kill(-1, SIGSTOP);
|
||||||
/* Signal all processes except those in our session */
|
/* Signal all processes except those in our session */
|
||||||
while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID))) {
|
while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID)) != NULL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (p->sid == (unsigned)sid
|
if (p->sid == (unsigned)sid
|
||||||
|| p->pid == (unsigned)pid
|
|| p->pid == (unsigned)pid
|
||||||
|| p->pid == 1)
|
|| p->pid == 1
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* All remaining args must be -o PID options.
|
/* All remaining args must be -o PID options.
|
||||||
* Check p->pid against them. */
|
* Check p->pid against them. */
|
||||||
@ -255,9 +257,10 @@ int kill_main(int argc, char **argv)
|
|||||||
pid = bb_strtoi(arg, &end, 10);
|
pid = bb_strtoi(arg, &end, 10);
|
||||||
if (errno && (errno != EINVAL || *end != ' ')) {
|
if (errno && (errno != EINVAL || *end != ' ')) {
|
||||||
bb_error_msg("invalid number '%s'", arg);
|
bb_error_msg("invalid number '%s'", arg);
|
||||||
*end = '\0';
|
|
||||||
errors++;
|
errors++;
|
||||||
} else if (kill(pid, signo) != 0) {
|
break;
|
||||||
|
}
|
||||||
|
if (kill(pid, signo) != 0) {
|
||||||
bb_perror_msg("can't kill pid %d", (int)pid);
|
bb_perror_msg("can't kill pid %d", (int)pid);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user