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 <wollman@khavrinen.lcs.mit.edu> suggests
		SIOCGIFCONF should be dropped in favor of a sysctl mechanism.
This commit is contained in:
Archie Cobbs 1999-06-05 05:52:52 +00:00
parent 2c7b227278
commit 3816c56cc1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=47753

View File

@ -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 @@ nextif:
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;
}