Fix boundary check of sockaddr array.

Reported by:	uqs
This commit is contained in:
Hiroki Sato 2013-08-01 04:50:46 +00:00
parent 9e1db66eb4
commit 15768a8b07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253852

View File

@ -1146,6 +1146,8 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags)
char *q;
#endif
if (idx < 0 || idx >= RTAX_MAX)
usage("internal error");
if (af == 0) {
#if defined(INET)
af = AF_INET;
@ -1162,9 +1164,6 @@ getaddr(int idx, char *str, struct hostent **hpp, int nrflags)
hpp = NULL;
#endif
rtm_addrs |= (1 << idx);
if (idx > RTAX_MAX)
usage("internal error");
sa = (struct sockaddr *)&so[idx];
sa->sa_family = af;
sa->sa_len = aflen;