diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-09-17 21:10:11 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-09-17 21:10:11 +0000 |
commit | aa4390fc9b4ea1f8c7286dbf6da0515ae29906bc (patch) | |
tree | 139bf59123d9d177134e7a030e84bfaa2553d7a5 /usr.sbin/rarpd/rarpd.c | |
parent | 57960caf83bdc7fd8bd65fed2df8620e0fc06001 (diff) |
If sa_len >sizeof(struct sockaddr) limit it there. Taken from ifconfig(8),
Also enhance the SIOCGIFFLAGS error message with the interface name.
Diffstat (limited to 'usr.sbin/rarpd/rarpd.c')
-rw-r--r-- | usr.sbin/rarpd/rarpd.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/rarpd/rarpd.c b/usr.sbin/rarpd/rarpd.c index 8649d7a1008..05a5d2c779e 100644 --- a/usr.sbin/rarpd/rarpd.c +++ b/usr.sbin/rarpd/rarpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rarpd.c,v 1.13 1997/09/12 04:07:20 millert Exp $ */ +/* $OpenBSD: rarpd.c,v 1.14 1997/09/17 21:10:10 niklas Exp $ */ /* $NetBSD: rarpd.c,v 1.12 1996/03/21 18:28:23 jtc Exp $ */ /* @@ -28,7 +28,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char rcsid[] = "$OpenBSD: rarpd.c,v 1.13 1997/09/12 04:07:20 millert Exp $"; +static char rcsid[] = "$OpenBSD: rarpd.c,v 1.14 1997/09/17 21:10:10 niklas Exp $"; #endif @@ -261,11 +261,14 @@ init_all() ifr = ifc.ifc_req; for (i = 0; i < ifc.ifc_len; i += len, ifr = (struct ifreq *)((caddr_t)ifr + len)) { - len = sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len; + len = sizeof(ifr->ifr_name) + + (ifr->ifr_addr.sa_len > sizeof(struct sockaddr) ? + ifr->ifr_addr.sa_len : sizeof(struct sockaddr)); + if (ioctl(fd, SIOCGIFFLAGS, (caddr_t)ifr) < 0) { free(inbuf); - err(FATAL, "init_all: SIOCGIFFLAGS: %s", - strerror(errno)); + err(FATAL, "init_all: SIOCGIFFLAGS %s: %s", + ifr->ifr_name, strerror(errno)); /* NOTREACHED */ } if ((ifr->ifr_flags & |