summaryrefslogtreecommitdiff
path: root/sbin/ping/ping.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-05-17 01:46:52 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-05-17 01:46:52 +0000
commit46229836116cdfbe0ea8be9246210d36813bc71b (patch)
tree03d356311093cbcdad18219f9723873c46887d6d /sbin/ping/ping.c
parent06be7a33ab8f8c60ba059901e263987804cb699a (diff)
Unroll that last patch, Theo thinks there's a better way of solving
the problem.
Diffstat (limited to 'sbin/ping/ping.c')
-rw-r--r--sbin/ping/ping.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 91d1eaca3ab..9b2181143ee 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping.c,v 1.34 1998/05/16 21:14:17 angelos Exp $ */
+/* $OpenBSD: ping.c,v 1.35 1998/05/17 01:46:51 angelos Exp $ */
/* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */
/*
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: ping.c,v 1.34 1998/05/16 21:14:17 angelos Exp $";
+static char rcsid[] = "$OpenBSD: ping.c,v 1.35 1998/05/17 01:46:51 angelos Exp $";
#endif
#endif /* not lint */
@@ -156,7 +156,6 @@ long nreceived; /* # of packets we got back */
long nrepeats; /* number of duplicates */
long ntransmitted; /* sequence # for outbound packets = #sent */
int interval = 1; /* interval between packets */
-volatile time_t lasttime; /* avoid DOS attack that involves SIGALRMs */
/* timing */
int timing; /* flag to do timing */
@@ -214,8 +213,6 @@ main(argc, argv)
setuid(getuid());
preload = 0;
- lasttime = 0;
-
datap = &outpack[8 + sizeof(struct tvi)];
while ((ch = getopt(argc, argv, "DI:LRS:c:dfh:i:l:np:qrs:T:t:vw:")) != -1)
switch(ch) {
@@ -524,36 +521,21 @@ catcher()
{
int waittime;
int save_errno = errno;
- time_t timenow;
-
- if (nreceived) {
- waittime = 2 * tmax / 1000000;
- if (!waittime)
- waittime = 1;
- } else
- waittime = maxwait;
-
- /*
- * Die if SIGALRM is caught earlier than it should have been. This
- * is usually the result of someone sending thousands of SIGALRMs
- * in an attempt to simulate a ping -f (flood).
- */
-
- if (time((time_t *)&timenow) < lasttime + waittime)
- exit(0);
-
- lasttime = timenow;
pinger();
-
(void)signal(SIGALRM, catcher);
if (!npackets || ntransmitted < npackets)
alarm((u_int)interval);
else {
+ if (nreceived) {
+ waittime = 2 * tmax / 1000000;
+ if (!waittime)
+ waittime = 1;
+ } else
+ waittime = maxwait;
(void)signal(SIGALRM, finish);
(void)alarm((u_int)waittime);
}
-
errno = save_errno;
}