aboutsummaryrefslogtreecommitdiff
path: root/poweroff.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-07-05 16:09:32 +0000
committerEric Andersen <andersen@codepoet.org>2001-07-05 16:09:32 +0000
commit332394b577d75669cd30c3ea884e9152d63366f8 (patch)
tree82258933d427e54a38477106b221e21bcdd1232e /poweroff.c
parentd50a61956c032c9b80bee7dc58a931318d8f38da (diff)
downloadbusybox-332394b577d75669cd30c3ea884e9152d63366f8.tar.gz
Be extra extra careful about what we dereference.
Diffstat (limited to 'poweroff.c')
-rw-r--r--poweroff.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/poweroff.c b/poweroff.c
index 007099d4d..8bb20e9bb 100644
--- a/poweroff.c
+++ b/poweroff.c
@@ -28,7 +28,10 @@ extern int poweroff_main(int argc, char **argv)
{
#ifdef BB_FEATURE_LINUXRC
/* don't assume init's pid == 1 */
- return(kill(*(find_pid_by_name("init")), SIGUSR2));
+ pid_t *pid = find_pid_by_name("init");
+ if (!pid || *pid<=0)
+ error_msg_and_die("no process killed");
+ return(kill(*pid, SIGUSR2));
#else
return(kill(1, SIGUSR2));
#endif