summaryrefslogtreecommitdiff
path: root/usr.sbin/traceroute
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-06-11 10:17:05 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-06-11 10:17:05 +0000
commitef3c6345daa6e59d180c9a20b6a10bd0614f8044 (patch)
tree2fbca546b04e8fc015f4093b0dd7b235d00f224f /usr.sbin/traceroute
parentcdf65dd83524800b1e712e07d6545d74174b123d (diff)
dynamic fd_set
Diffstat (limited to 'usr.sbin/traceroute')
-rw-r--r--usr.sbin/traceroute/traceroute.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c
index cc12edc524e..c2c0677a0f2 100644
--- a/usr.sbin/traceroute/traceroute.c
+++ b/usr.sbin/traceroute/traceroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute.c,v 1.21 1997/06/11 06:47:24 denny Exp $ */
+/* $OpenBSD: traceroute.c,v 1.22 1997/06/11 10:17:04 deraadt Exp $ */
/* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */
/*-
@@ -629,13 +629,16 @@ wait_for_reply(sock, from, sent)
struct sockaddr_in *from;
struct timeval *sent;
{
- fd_set fds;
struct timeval now, wait;
- int cc = 0;
+ int cc = 0, fdsn;
int fromlen = sizeof (*from);
+ fd_set *fdsp;
- FD_ZERO(&fds);
- FD_SET(sock, &fds);
+ fdsn = howmany(sock+1, NFDBITS) * sizeof(fd_mask);
+ if ((fdsp = (fd_set *)malloc(fdsn)) == NULL)
+ err(1, "malloc");
+ memset(fdsp, 0, fdsn);
+ FD_SET(sock, fdsp);
gettimeofday(&now, NULL);
wait.tv_sec = (sent->tv_sec + waittime) - now.tv_sec;
wait.tv_usec = sent->tv_usec - now.tv_usec;
@@ -646,10 +649,11 @@ wait_for_reply(sock, from, sent)
if (wait.tv_sec < 0)
wait.tv_sec = wait.tv_usec = 0;
- if (select(sock+1, &fds, (fd_set *)0, (fd_set *)0, &wait) > 0)
+ if (select(sock+1, fdsp, (fd_set *)0, (fd_set *)0, &wait) > 0)
cc=recvfrom(s, (char *)packet, sizeof(packet), 0,
(struct sockaddr *)from, &fromlen);
+ free(fdsp);
return(cc);
}