aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Fomenko <ext-alexey.fomenko@nokia.com>2011-12-22 11:38:57 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-12-22 11:38:57 +0100
commit6a93212b54327c77383d88efd581475105f3b72a (patch)
tree5e5579dfc218ee79e8aec1c66410007b4134c88a
parent83f103b30e41ab038e45661df97625f655abe491 (diff)
downloadbusybox-w32-6a93212b54327c77383d88efd581475105f3b72a.tar.gz
busybox-w32-6a93212b54327c77383d88efd581475105f3b72a.tar.bz2
busybox-w32-6a93212b54327c77383d88efd581475105f3b72a.zip
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>
-rw-r--r--procps/kill.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/procps/kill.c b/procps/kill.c
index 224e5ad1a..b267a7aaf 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -165,13 +165,15 @@ int kill_main(int argc, char **argv)
165 /* Stop all processes */ 165 /* Stop all processes */
166 kill(-1, SIGSTOP); 166 kill(-1, SIGSTOP);
167 /* Signal all processes except those in our session */ 167 /* Signal all processes except those in our session */
168 while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID))) { 168 while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_SID)) != NULL) {
169 int i; 169 int i;
170 170
171 if (p->sid == (unsigned)sid 171 if (p->sid == (unsigned)sid
172 || p->pid == (unsigned)pid 172 || p->pid == (unsigned)pid
173 || p->pid == 1) 173 || p->pid == 1
174 ) {
174 continue; 175 continue;
176 }
175 177
176 /* All remaining args must be -o PID options. 178 /* All remaining args must be -o PID options.
177 * Check p->pid against them. */ 179 * Check p->pid against them. */
@@ -255,9 +257,10 @@ int kill_main(int argc, char **argv)
255 pid = bb_strtoi(arg, &end, 10); 257 pid = bb_strtoi(arg, &end, 10);
256 if (errno && (errno != EINVAL || *end != ' ')) { 258 if (errno && (errno != EINVAL || *end != ' ')) {
257 bb_error_msg("invalid number '%s'", arg); 259 bb_error_msg("invalid number '%s'", arg);
258 *end = '\0';
259 errors++; 260 errors++;
260 } else if (kill(pid, signo) != 0) { 261 break;
262 }
263 if (kill(pid, signo) != 0) {
261 bb_perror_msg("can't kill pid %d", (int)pid); 264 bb_perror_msg("can't kill pid %d", (int)pid);
262 errors++; 265 errors++;
263 } 266 }