1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00

Fix a bug in cp += SA_SIZE() in RTA_* loop. This could prevent

RTA_IFP from displaying correctly in route get subcommand.

Spotted by:	dim
This commit is contained in:
Hiroki Sato 2013-07-24 04:05:48 +00:00
parent 15b5b0aca5
commit d2034d1b22
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253589

View File

@ -1699,16 +1699,15 @@ print_getmsg(struct rt_msghdr *rtm, int msglen, int fib)
return;
}
cp = ((char *)(rtm + 1));
for (i = 0; i < RTAX_MAX; i++) {
if (rtm->rtm_addrs & (1 << i))
for (i = 0; i < RTAX_MAX; i++)
if (rtm->rtm_addrs & (1 << i)) {
sp[i] = (struct sockaddr *)cp;
cp += SA_SIZE((struct sockaddr *)cp);
}
if (rtm->rtm_addrs & RTA_IFP) {
if (sp[RTAX_IFP]->sa_family != AF_LINK ||
((struct sockaddr_dl *)(void *)sp[RTAX_IFP])->sdl_nlen == 0)
cp += SA_SIZE((struct sockaddr *)cp);
}
if ((rtm->rtm_addrs & RTA_IFP) &&
(sp[RTAX_IFP]->sa_family != AF_LINK ||
((struct sockaddr_dl *)(void *)sp[RTAX_IFP])->sdl_nlen == 0))
sp[RTAX_IFP] = NULL;
}
if (sp[RTAX_DST] && sp[RTAX_NETMASK])
sp[RTAX_NETMASK]->sa_family = sp[RTAX_DST]->sa_family; /* XXX */
if (sp[RTAX_DST])