Date: Mon, 28 Feb 2000 14:23:11 +0900 From: Yoshinobu Inoue <shin@nd.net.fujitsu.co.jp> To: roberto@keltia.freenix.fr Cc: freebsd-current@FreeBSD.ORG Subject: Re: patches for SIOCGIFCONF Message-ID: <20000228142311L.shin@nd.net.fujitsu.co.jp> In-Reply-To: <20000228000209.A7561@keltia.freenix.fr> References: <20000228033148B.shin@nd.net.fujitsu.co.jp> <20000228000209.A7561@keltia.freenix.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
> > usr.sbin/xntpd/xntpd: > > These directories don't exist anymore in -CURRENT because we now have ntp4. Woops sorry, a machine in my home which I used to produce those diffs, still mistakenly had the directory. > > --- contrib/ntp/ntpd/ntp_io.c.orig Fri Jan 28 15:44:00 2000 > > +++ contrib/ntp/ntpd/ntp_io.c Mon Feb 28 02:26:46 2000 > > @@ -444,7 +444,7 @@ > > continue; > > } > > # endif /* SYS_WINNT */ > > - ifreq = *ifr; > > + memcpy(&ifreq, ifr, sizeof(ifreq)); > > inter_list[i].flags = 0; > > /* is it broadcast capable? */ > > # ifndef SYS_WINNT > > This one should be sent to the NTP guys before ntpd 4.1.0 goes out. OK, I sent it to mills@udel.edu. And I found that my patches to contrib/bind/lib/irs/gethotent.c needs a fix. - memcpy(&ifreq, cp, sizeof *ifreqs); + memcpy(ifreqp, cp, sizeof ifreqbuf); This is updated patches. Thanks, Yoshinobu Inoue --- contrib/bind/lib/irs/gethostent.c.orig Tue Nov 30 15:38:00 1999 +++ contrib/bind/lib/irs/gethostent.c Mon Feb 28 13:55:43 2000 @@ -462,13 +462,16 @@ static int scan_interfaces(int *have_v4, int *have_v6) { struct ifconf ifc; - struct ifreq ifreq; + struct ifreq* ifreqp; struct in_addr in4; struct in6_addr in6; char *buf = NULL, *cp, *cplim; + char ifreqbuf[IFNAMSIZ + sizeof(struct sockaddr_storage)]; static int bufsiz = 4095; int s, cpsize, n; + ifreqp = (struct ifreq *)ifreqbuf; + /* Set to zero. Used as loop terminators below. */ *have_v4 = *have_v6 = 0; @@ -504,7 +507,7 @@ * buffer we will grow it just in case and * retry. */ - if (ifc.ifc_len + 2 * sizeof(ifreq) < bufsiz) + if (ifc.ifc_len + 2 * sizeof(*ifreqp) < bufsiz) break; } #endif @@ -523,40 +526,40 @@ for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { - memcpy(&ifreq, cp, sizeof ifreq); + memcpy(ifreqp, cp, sizeof ifreqbuf); #ifdef HAVE_SA_LEN #ifdef FIX_ZERO_SA_LEN - if (ifreq.ifr_addr.sa_len == 0) - ifreq.ifr_addr.sa_len = 16; + if (ifreqp->ifr_addr.sa_len == 0) + ifreqp->ifr_addr.sa_len = 16; #endif #ifdef HAVE_MINIMUM_IFREQ - cpsize = sizeof ifreq; - if (ifreq.ifr_addr.sa_len > sizeof (struct sockaddr)) - cpsize += (int)ifreq.ifr_addr.sa_len - + cpsize = sizeof *ifreqp; + if (ifreqp->ifr_addr.sa_len > sizeof (struct sockaddr)) + cpsize += (int)ifreqp->ifr_addr.sa_len - (int)(sizeof (struct sockaddr)); #else - cpsize = sizeof ifreq.ifr_name + ifreq.ifr_addr.sa_len; + cpsize = sizeof ifreqp->ifr_name + ifreqp->ifr_addr.sa_len; #endif /* HAVE_MINIMUM_IFREQ */ #elif defined SIOCGIFCONF_ADDR - cpsize = sizeof ifreq; + cpsize = sizeof *ifreqp; #else - cpsize = sizeof ifreq.ifr_name; + cpsize = sizeof ifreq->ifr_name; /* XXX maybe this should be a hard error? */ - if (ioctl(s, SIOCGIFADDR, (char *)&ifreq) < 0) + if (ioctl(s, SIOCGIFADDR, (char *)ifreqp) < 0) continue; #endif - switch (ifreq.ifr_addr.sa_family) { + switch (ifreqp->ifr_addr.sa_family) { case AF_INET: if (*have_v4 == 0) { memcpy(&in4, &((struct sockaddr_in *) - &ifreq.ifr_addr)->sin_addr, sizeof in4); + &ifreqp->ifr_addr)->sin_addr, sizeof in4); if (in4.s_addr == INADDR_ANY) break; - n = ioctl(s, SIOCGIFFLAGS, (char *)&ifreq); + n = ioctl(s, SIOCGIFFLAGS, (char *)ifreqp); if (n < 0) break; - if ((ifreq.ifr_flags & IFF_UP) == 0) + if ((ifreqp->ifr_flags & IFF_UP) == 0) break; *have_v4 = 1; } @@ -565,13 +568,13 @@ if (*have_v6 == 0) { memcpy(&in6, &((struct sockaddr_in6 *) - &ifreq.ifr_addr)->sin6_addr, sizeof in6); + &ifreqp->ifr_addr)->sin6_addr, sizeof in6); if (memcmp(&in6, &in6addr_any, sizeof in6) == 0) break; - n = ioctl(s, SIOCGIFFLAGS, (char *)&ifreq); + n = ioctl(s, SIOCGIFFLAGS, (char *)ifreqp); if (n < 0) break; - if ((ifreq.ifr_flags & IFF_UP) == 0) + if ((ifreqp->ifr_flags & IFF_UP) == 0) break; *have_v6 = 1; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000228142311L.shin>