diff options
author | kris <kris@FreeBSD.org> | 2000-10-08 08:02:35 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2000-10-08 08:02:35 +0000 |
commit | 2873286b5607ff924349475877c116146131efe8 (patch) | |
tree | ea16c76b316e4151fe2384e18e5b5f7c37430987 /sbin/ping6 | |
parent | bf6b0f4463166e362011c5463d166f823885f3af (diff) | |
download | FreeBSD-src-2873286b5607ff924349475877c116146131efe8.zip FreeBSD-src-2873286b5607ff924349475877c116146131efe8.tar.gz |
Don't overflow our fd_set. This is not a full sync with KAME because there
are a whole lot of other changes which may not be suitable for us.
Obtained from: KAME
Diffstat (limited to 'sbin/ping6')
-rw-r--r-- | sbin/ping6/ping6.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index e258013..f853534 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -112,10 +112,7 @@ static const char rcsid[] = #include <net/if.h> #include <net/route.h> -#include <netinet/in_systm.h> #include <netinet/in.h> -#include <netinet/ip.h> -#include <netinet/ip_var.h> #include <netinet/ip6.h> #include <netinet/icmp6.h> #include <arpa/inet.h> @@ -268,7 +265,8 @@ main(argc, argv) struct sockaddr_in6 from; struct timeval timeout; struct addrinfo hints; - fd_set fdset; + fd_set *fdmaskp; + int fdmasks; register int cc, i; int ch, fromlen, hold, packlen, preload, optval, ret_ga; u_char *datap, *packet; @@ -870,9 +868,10 @@ main(argc, argv) (void)setitimer(ITIMER_REAL, &itimer, NULL); } - FD_ZERO(&fdset); - timeout.tv_sec = 0; - timeout.tv_usec = 10000; + fdmasks = howmany(s+1, NFDBITS); + if ((fdmaskp = malloc(fdmasks)) == NULL) + err(1, "malloc"); + for (;;) { struct msghdr m; struct cmsghdr *cm; @@ -881,8 +880,11 @@ main(argc, argv) if (options & F_FLOOD) { pinger(); - FD_SET(s, &fdset); - if (select(s + 1, &fdset, NULL, NULL, &timeout) < 1) + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + memset(fdmaskp, 0, fdmasks); + FD_SET(s, fdmaskp); + if (select(s + 1, fdmaskp, NULL, NULL, &timeout) < 1) continue; } fromlen = sizeof(from); |