From e413b4ce15cf61c0d959344b945b3229adfd782f Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Sat, 29 Jul 1995 08:25:53 +0000 Subject: [PATCH] * localaddr.c (krb5_crypto_os_localaddr): Don't bash the return from SIOCGIFCONF with the output of a SIOCGIFFLAGS. Duh. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6356 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/crypto/os/ChangeLog | 5 +++++ src/lib/crypto/os/localaddr.c | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/lib/crypto/os/ChangeLog b/src/lib/crypto/os/ChangeLog index 73381f574..a054acb27 100644 --- a/src/lib/crypto/os/ChangeLog +++ b/src/lib/crypto/os/ChangeLog @@ -1,3 +1,8 @@ +Sat Jul 29 03:17:21 1995 Tom Yu + + * localaddr.c (krb5_crypto_os_localaddr): Don't bash the return + from SIOCGIFCONF with the output of a SIOCGIFFLAGS. Duh. + Wed Jul 19 17:17:54 1995 Tom Yu * localaddr.c: also add definition of max if it's not there. diff --git a/src/lib/crypto/os/localaddr.c b/src/lib/crypto/os/localaddr.c index 2fcb96412..7ab153a8a 100644 --- a/src/lib/crypto/os/localaddr.c +++ b/src/lib/crypto/os/localaddr.c @@ -75,7 +75,8 @@ */ /* - * BSD 4.4 defines the size of an ifreq to be max(sizeof(ifreq), sizeof(ifr.ifr_name)+ifreq.ifr_ifr_addr.sa_len + * BSD 4.4 defines the size of an ifreq to be + * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len * However, under earlier systems, sa_len isn't present, so the size is * just sizeof(struct ifreq) */ @@ -108,7 +109,7 @@ krb5_error_code INTERFACE krb5_crypto_os_localaddr(addr) krb5_address ***addr; { - struct ifreq *ifr; + struct ifreq *ifr, ifreq; struct ifconf ifc; int s, code, n, i; char buf[1024]; @@ -135,23 +136,20 @@ n_found = 0; for (i = 0; i < n; i+= ifreq_size(*ifr) ) { krb5_address *address; ifr = (struct ifreq *)((caddr_t) ifc.ifc_buf+i); - - if (ioctl (s, SIOCGIFFLAGS, (char *)ifr) < 0) + + strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof (ifreq.ifr_name)); + if (ioctl (s, SIOCGIFFLAGS, (char *)&ifreq) < 0) continue; #ifdef IFF_LOOPBACK - if (ifr->ifr_flags & IFF_LOOPBACK) + if (ifreq.ifr_flags & IFF_LOOPBACK) continue; #endif - if (!(ifr->ifr_flags & IFF_UP)) + if (!(ifreq.ifr_flags & IFF_UP)) /* interface is down; skip */ continue; - if (ioctl (s, SIOCGIFADDR, (char *)ifr) < 0) - /* can't get address */ - continue; - /* ifr->ifr_addr has what we want! */ switch (ifr->ifr_addr.sa_family) { #ifdef KRB5_USE_INET @@ -183,7 +181,7 @@ n_found = 0; case AF_XNS: { struct sockaddr_ns *ns = - (struct sockaddr_ns *)&ifr->ifr_addr; + (struct sockaddr_ns *)&ifr->ifr_addr; address = (krb5_address *) malloc (sizeof (krb5_address) + sizeof (struct ns_addr)); if (address) { -- 2.26.2