Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sbin/ping Pullup 1.56 [itojun]:



details:   https://anonhg.NetBSD.org/src/rev/e1b1d5384b32
branches:  netbsd-1-5
changeset: 489863:e1b1d5384b32
user:      tv <tv%NetBSD.org@localhost>
date:      Wed Oct 18 02:04:49 2000 +0000

description:
Pullup 1.56 [itojun]:
avoid fd_set overflow.

diffstat:

 sbin/ping/ping.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (60 lines):

diff -r 85a380b14c2f -r e1b1d5384b32 sbin/ping/ping.c
--- a/sbin/ping/ping.c  Wed Oct 18 02:03:49 2000 +0000
+++ b/sbin/ping/ping.c  Wed Oct 18 02:04:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ping.c,v 1.55.4.1 2000/10/18 00:39:47 tv Exp $ */
+/*     $NetBSD: ping.c,v 1.55.4.2 2000/10/18 02:04:49 tv Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -62,7 +62,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.55.4.1 2000/10/18 00:39:47 tv Exp $");
+__RCSID("$NetBSD: ping.c,v 1.55.4.2 2000/10/18 02:04:49 tv Exp $");
 #endif
 
 #include <stdio.h>
@@ -666,8 +666,8 @@
        int fromlen;
        double sec, last, d_last;
        struct timeval timeout;
-       fd_set fdmask;
-
+       fd_set *fdmaskp;
+       size_t nfdmask;
 
        (void)gettimeofday(&clear_cache,0);
        if (maxwait != 0) {
@@ -678,7 +678,10 @@
                d_last = 365*24*60*60;
        }
 
-       FD_ZERO(&fdmask);
+       nfdmask = howmany(s + 1, NFDBITS);
+       if ((fdmaskp = malloc(nfdmask)) == NULL)
+               err(1, "malloc");
+       memset(fdmaskp, 0, nfdmask);
        do {
                (void)gettimeofday(&now,0);
 
@@ -713,8 +716,8 @@
 
                sec_to_timeval(sec, &timeout);
 
-               FD_SET(s, &fdmask);
-               cc = select(s+1, &fdmask, 0, 0, &timeout);
+               FD_SET(s, fdmaskp);
+               cc = select(s+1, fdmaskp, 0, 0, &timeout);
                if (cc <= 0) {
                        if (cc < 0) {
                                if (errno == EINTR)
@@ -742,6 +745,7 @@
 
        } while (nreceived < npackets
                 && (nreceived == 0 || !(pingflags & F_ONCE)));
+       free(fdmaskp);
 
        finish(0);
 }



Home | Main Index | Thread Index | Old Index