summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-18 05:46:11 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-18 05:46:11 +0000
commit9ffe3780a83c720edb60011048f4137173cb3b6f (patch)
tree58ae329c0ed5dd105125a240892f3c88fd297a17 /sbin
parent6cdc235fe519a60e5ae5e4bfd98e23cf8c6f4754 (diff)
avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ifconfig/ifconfig.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 797d008b75b..d72f56825b0 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.29 2000/02/18 05:23:55 itojun Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.30 2000/02/18 05:46:10 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.29 2000/02/18 05:23:55 itojun Exp $";
+static char rcsid[] = "$OpenBSD: ifconfig.c,v 1.30 2000/02/18 05:46:10 itojun Exp $";
#endif
#endif /* not lint */
@@ -558,8 +558,9 @@ printif(ifrm, ifaliases)
char *inbuf = NULL;
struct ifconf ifc;
struct ifreq ifreq, *ifrp;
- int i, len = 8192;
+ int i, siz, len = 8192;
int count = 0, noinet = 1;
+ char ifrbuf[8192];
getsock(af);
if (s < 0)
@@ -579,9 +580,15 @@ printif(ifrm, ifaliases)
ifreq.ifr_name[0] = '\0';
for (i = 0; i < ifc.ifc_len; ) {
ifrp = (struct ifreq *)((caddr_t)ifc.ifc_req + i);
- i += sizeof(ifrp->ifr_name) +
+ siz = sizeof(ifrp->ifr_name) +
(ifrp->ifr_addr.sa_len > sizeof(struct sockaddr) ?
ifrp->ifr_addr.sa_len : sizeof(struct sockaddr));
+ i += siz;
+ /* avoid alignment issue */
+ if (sizeof(ifrbuf) < siz)
+ errx(1, "ifr too big");
+ memcpy(ifrbuf, ifrp, siz);
+ ifrp = (struct ifreq *)ifrbuf;
if (ifrm && strncmp(ifrm->ifr_name, ifrp->ifr_name,
sizeof(ifrp->ifr_name)))