aboutsummaryrefslogtreecommitdiff
path: root/sbin/shutdown
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>1999-06-18 14:26:07 +0000
committerRuslan Ermilov <ru@FreeBSD.org>1999-06-18 14:26:07 +0000
commit966ea00a573b26a950eab7852ee4b7472caf81c7 (patch)
tree9b701d10cde4bcc2eb21fc4a030d360895fcf61e /sbin/shutdown
parent08da4867ae0c63365c7cbef1f5e2e45ab8817d8a (diff)
downloadsrc-966ea00a573b26a950eab7852ee4b7472caf81c7.tar.gz
src-966ea00a573b26a950eab7852ee4b7472caf81c7.zip
Fix a coredump with negative (due to overflow) offset values.
Notes
Notes: svn path=/head/; revision=48004
Diffstat (limited to 'sbin/shutdown')
-rw-r--r--sbin/shutdown/shutdown.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 680925fc970a..03a1866b1da2 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95";
#endif
static const char rcsid[] =
- "$Id: shutdown.c,v 1.15 1998/12/11 11:04:19 bde Exp $";
+ "$Id: shutdown.c,v 1.16 1998/12/11 11:21:47 bde Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -232,7 +232,7 @@ loop()
if (tp->timeleft < offset)
(void)sleep((u_int)(offset - tp->timeleft));
else {
- while (offset < tp->timeleft)
+ while (tp->timeleft && offset < tp->timeleft)
++tp;
/*
* Warn now, if going to sleep more than a fifth of
@@ -392,7 +392,8 @@ getoffset(timearg)
if (*timearg == '+') { /* +minutes */
if (!isdigit(*++timearg))
badtime();
- offset = atoi(timearg) * 60;
+ if ((offset = atoi(timearg) * 60) < 0)
+ badtime();
shuttime = now + offset;
return;
}