summaryrefslogtreecommitdiffstats
path: root/usr.sbin/traceroute6
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2000-10-08 07:52:08 +0000
committerkris <kris@FreeBSD.org>2000-10-08 07:52:08 +0000
commit96f85c70726a94ab2be7e3a1fd56ef6c02f0b318 (patch)
tree20e442b137f39aff54eabe50cf56b93ad1851c6d /usr.sbin/traceroute6
parentc3fda0391484a6ce7f192c6d3a50d6e247174117 (diff)
downloadFreeBSD-src-96f85c70726a94ab2be7e3a1fd56ef6c02f0b318.zip
FreeBSD-src-96f85c70726a94ab2be7e3a1fd56ef6c02f0b318.tar.gz
Sync with KAME. Don't write past the end of the fd_set.
Obtained from: KAME
Diffstat (limited to 'usr.sbin/traceroute6')
-rw-r--r--usr.sbin/traceroute6/traceroute6.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index d971318..d715cc3 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -1,4 +1,4 @@
-/* $KAME: traceroute6.c,v 1.29 2000/06/12 16:29:18 itojun Exp $ */
+/* $KAME: traceroute6.c,v 1.32 2000/07/07 12:21:34 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -264,6 +264,9 @@ static const char rcsid[] =
#include <netdb.h>
#include <stdio.h>
#include <err.h>
+#ifdef HAVE_POLL
+#include <poll.h>
+#endif
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -869,18 +872,36 @@ wait_for_reply(sock, mhdr)
int sock;
struct msghdr *mhdr;
{
- fd_set fds;
- struct timeval wait;
+#ifdef HAVE_POLL
+ struct pollfd pfd[1];
int cc = 0;
- FD_ZERO(&fds);
- FD_SET(sock, &fds);
+ pfd[0].fd = sock;
+ pfd[0].events = POLLIN;
+ pfd[0].revents = 0;
+
+ if (poll(pfd, 1, waittime * 1000) > 0)
+ cc = recvmsg(rcvsock, mhdr, 0);
+
+ return(cc);
+#else
+ fd_set *fdsp;
+ struct timeval wait;
+ int cc = 0, fdsn;
+
+ 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);
wait.tv_sec = waittime; 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 = recvmsg(rcvsock, mhdr, 0);
+ free(fdsp);
return(cc);
+#endif
}
#ifdef IPSEC
OpenPOWER on IntegriCloud