Where are all the IPv6 zealots hiding? -- :wq Claudio
On Mon, Jul 04, 2011 at 07:57:01AM +0200, Claudio Jeker wrote: > Doing (ifam + 1) to find the start of the sockaddrs in a rt msg is wrong > better use the rtm_hdrlen field. > > I only compile tested this since I have nothing that uses the IPv6 > autoconfiguration crap. > -- > :wq Claudio > > Index: usr.sbin/rtadvd/if.c > =================================================================== > RCS file: /cvs/src/usr.sbin/rtadvd/if.c,v > retrieving revision 1.23 > diff -u -p -r1.23 if.c > --- usr.sbin/rtadvd/if.c 21 May 2010 13:41:23 -0000 1.23 > +++ usr.sbin/rtadvd/if.c 4 Jul 2011 05:54:44 -0000 > @@ -269,9 +269,11 @@ get_next_msg(char *buf, char *lim, int i > case RTM_NEWADDR: > case RTM_DELADDR: > ifam = (struct ifa_msghdr *)rtm; > + if (ifindex && ifam->ifam_index != ifindex) > + continue; > > /* address related checks */ > - sa = (struct sockaddr *)(ifam + 1); > + sa = (struct sockaddr *)((char *)rtm + rtm->rtm_hdrlen); > get_rtaddrs(ifam->ifam_addrs, sa, rti_info); > if ((ifa = rti_info[RTAX_IFA]) == NULL || > (ifa->sa_family != AF_INET && > @@ -283,11 +285,8 @@ get_next_msg(char *buf, char *lim, int i > IN6_IS_ADDR_MULTICAST(&SIN6(ifa)->sin6_addr))) > continue; > > - if (ifindex && ifam->ifam_index != ifindex) > - continue; > - > /* found */ > - *lenp = ifam->ifam_msglen; > + *lenp = rtm->rtm_msglen; > return (char *)rtm; > /* NOTREACHED */ > case RTM_IFINFO:
