aboutsummaryrefslogtreecommitdiff
path: root/sbin/route/route.c
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2013-07-24 04:05:48 +0000
committerHiroki Sato <hrs@FreeBSD.org>2013-07-24 04:05:48 +0000
commitd2034d1b22b1c9a551fa3cd7d5143bb1d2dd4602 (patch)
tree0dbde06da080f9db5eaf6e5dc0bfec7ea819b24d /sbin/route/route.c
parent15b5b0aca529665f1d8ee74bdf46d33ee816974e (diff)
downloadsrc-d2034d1b22b1c9a551fa3cd7d5143bb1d2dd4602.tar.gz
src-d2034d1b22b1c9a551fa3cd7d5143bb1d2dd4602.zip
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
Notes
Notes: svn path=/head/; revision=253589
Diffstat (limited to 'sbin/route/route.c')
-rw-r--r--sbin/route/route.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 6bfca1377cbc..ebf95c65d8cb 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -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])