[PATCH] kill: fix segfault in arguments parsing

Alexey Fomenko ext-alexey.fomenko at nokia.com
Wed Dec 21 14:14:58 UTC 2011


Dont's use temporary pointer *end when it can point to nowhere,
instead terminate the *arg itself and skip rest of cycle.

Signed-off-by: Alexey Fomenko <ext-alexey.fomenko at nokia.com>
---
 procps/kill.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/procps/kill.c b/procps/kill.c
index 224e5ad..f17323d 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -255,8 +255,9 @@ int kill_main(int argc, char **argv)
 			pid = bb_strtoi(arg, &end, 10);
 			if (errno && (errno != EINVAL || *end != ' ')) {
 				bb_error_msg("invalid number '%s'", arg);
-				*end = '\0';
+				*arg = '\0'; /* terminate *arg and leave cycle, end can point to nowhere */
 				errors++;
+				continue;
 			} else if (kill(pid, signo) != 0) {
 				bb_perror_msg("can't kill pid %d", (int)pid);
 				errors++;
-- 
1.7.2.5



More information about the busybox mailing list