diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-02-18 08:13:32 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-02-18 08:13:32 +0000 |
commit | e34fff118f855858d683eca5a633fe7a3ec0bf15 (patch) | |
tree | 5c05144efd286f41434cdfc2a0df8f970ccadb72 /sbin/ifconfig | |
parent | eeb59fb7f09b4ceb33700a7e5aa93ce303b622ad (diff) |
more alignment fix for SIOCGIFCONF.
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index d72f56825b0..ccefbaa580a 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.30 2000/02/18 05:46:10 itojun Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.31 2000/02/18 08:13:31 itojun Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -81,7 +81,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.30 2000/02/18 05:46:10 itojun Exp $"; +static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.31 2000/02/18 08:13:31 itojun Exp $"; #endif #endif /* not lint */ @@ -580,9 +580,11 @@ printif(ifrm, ifaliases) ifreq.ifr_name[0] = '\0'; for (i = 0; i < ifc.ifc_len; ) { ifrp = (struct ifreq *)((caddr_t)ifc.ifc_req + i); - siz = sizeof(ifrp->ifr_name) + - (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr) ? - ifrp->ifr_addr.sa_len : sizeof(struct sockaddr)); + memcpy(ifrbuf, ifrp, sizeof(*ifrp)); + siz = ((struct ifreq *)ifrbuf)->ifr_addr.sa_len; + if (siz < sizeof(ifrp->ifr_addr)) + siz = sizeof(ifrp->ifr_addr); + siz += sizeof(ifrp->ifr_name); i += siz; /* avoid alignment issue */ if (sizeof(ifrbuf) < siz) @@ -595,8 +597,7 @@ printif(ifrm, ifaliases) continue; strncpy(name, ifrp->ifr_name, sizeof(ifrp->ifr_name)); if (ifrp->ifr_addr.sa_family == AF_LINK) { - memcpy(&ifr, ifrp, sizeof(ifr)); - ifreq = ifr; + ifreq = ifr = *ifrp; if (getinfo(&ifreq) < 0) continue; status(1); @@ -612,7 +613,7 @@ printif(ifrm, ifaliases) if (ifaliases == 0 && noinet == 0) continue; #endif - memcpy(&ifr, ifrp, sizeof(ifr)); + ifr = *ifrp; #ifdef INET6 /* quickhack: sizeof(ifr) < sizeof(ifr6) */ if (ifrp->ifr_addr.sa_family == AF_INET6) |