From 3816c56cc19103d76ba3208c67ae91983dba4989 Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Sat, 5 Jun 1999 05:52:52 +0000 Subject: [PATCH] When incrementing through a SIOCGIFCONF list, enforce a lower limit of sizeof(ifr->ifr_addr) for the variable length field ifr->ifr_addr.sa_len. Otherwise the increment will be wrong in certain cases. Obtained from: Whistle source tree For the record: Garrett Wollman suggests SIOCGIFCONF should be dropped in favor of a sysctl mechanism. --- usr.sbin/arp/arp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/arp/arp.c b/usr.sbin/arp/arp.c index 6326fb7f992f..efe4ab1697f8 100644 --- a/usr.sbin/arp/arp.c +++ b/usr.sbin/arp/arp.c @@ -45,7 +45,7 @@ static char const copyright[] = static char const sccsid[] = "@(#)from: arp.c 8.2 (Berkeley) 1/2/94"; #endif static const char rcsid[] = - "$Id: arp.c,v 1.14 1998/01/16 17:38:51 bde Exp $"; + "$Id: arp.c,v 1.15 1999/03/10 10:11:43 julian Exp $"; #endif /* not lint */ /* @@ -696,8 +696,8 @@ get_ether_addr(u_long ipaddr, u_char *hwaddr) break; } nextif: - ifr = (struct ifreq *) - ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len); + ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + + MAX(ifr->ifr_addr.sa_len, sizeof(ifr->ifr_addr))); } if (ifr >= ifend) { @@ -725,8 +725,8 @@ get_ether_addr(u_long ipaddr, u_char *hwaddr) printf("\n"); return dla->sdl_alen; } - ifr = (struct ifreq *) - ((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len); + ifr = (struct ifreq *) ((char *)&ifr->ifr_addr + + MAX(ifr->ifr_addr.sa_len, sizeof(ifr->ifr_addr))); } return 0; }