Re: svn commit: r253504 - head/sbin/route
Ulrich Spörlein u...@freebsd.org wrote in 20130724130046.gd9...@acme.spoerlein.net: uq On Sat, 2013-07-20 at 16:46:51 +, Hiroki Sato wrote: uq Author: hrs uq Date: Sat Jul 20 16:46:51 2013 uq New Revision: 253504 uq URL: http://svnweb.freebsd.org/changeset/base/253504 uq uq Log: uq- Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_* uq as the argument. uq- Reduce unnecessary loop in print_getmsg(). uq uq Modified: uqhead/sbin/route/route.c uq uq Modified: head/sbin/route/route.c uq == uq --- head/sbin/route/route.c Sat Jul 20 15:58:43 2013 (r253503) uq +++ head/sbin/route/route.c Sat Jul 20 16:46:51 2013 (r253504) uq @@ -1105,7 +1105,7 @@ inet6_makenetandmask(struct sockaddr_in6 uq* returning 1 if a host address, 0 if a network address. uq*/ uq static int uq -getaddr(int which, char *str, struct hostent **hpp, int nrflags) uq +getaddr(int idx, char *str, struct hostent **hpp, int nrflags) uq { uqstruct sockaddr *sa; uq #if defined(INET) uq @@ -1130,36 +1130,16 @@ getaddr(int which, char *str, struct hos uqaflen = sizeof(struct sockaddr_dl); uq #endif uq} uq - rtm_addrs |= which; uq + rtm_addrs |= (1 idx); uq uq - switch (which) { uq - case RTA_DST: uq - sa = (struct sockaddr *)so[RTAX_DST]; uq - break; uq - case RTA_GATEWAY: uq - sa = (struct sockaddr *)so[RTAX_GATEWAY]; uq - break; uq - case RTA_NETMASK: uq - sa = (struct sockaddr *)so[RTAX_NETMASK]; uq - break; uq - case RTA_GENMASK: uq - sa = (struct sockaddr *)so[RTAX_GENMASK]; uq - break; uq - case RTA_IFA: uq - sa = (struct sockaddr *)so[RTAX_IFA]; uq - break; uq - case RTA_IFP: uq - sa = (struct sockaddr *)so[RTAX_IFP]; uq - break; uq - default: uq + if (idx RTAX_MAX) uqusage(internal error); uq - /*NOTREACHED*/ uq - } uq + sa = (struct sockaddr *)so[idx]; uq uq Coverity Scan flags this as an out-of-bounds write. RTAX_MAX is 8, so uq idx can be up to 8 (inclusive) in the check above. Do you want to check uq for idx = RTAX_MAX maybe? idx is also signed ... uq uq Coverity CID is 1054779, btw. Sorry for the delay. Thank you for pointing out it. Yes, the check was wrong by one. Fixed in r253852. -- Hiroki pgpzTdefq6VBC.pgp Description: PGP signature
Re: svn commit: r253504 - head/sbin/route
On Jul 24, 2013, at 06:06, Hiroki Sato h...@freebsd.org wrote: Dimitry Andric d...@freebsd.org wrote in 36e48152-1a64-432d-a32d-75059a56e...@freebsd.org: ... di This breaks /etc/rc.d/defaultroute, since it relies on route -n get di -inet default printing a line with interface: in it. ... Should be fixed in r253589. Sorry for the breakage. It works fine now. Thanks for the quick fix! -Dimitry ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r253504 - head/sbin/route
On Jul 20, 2013, at 18:46, Hiroki Sato h...@freebsd.org wrote: Author: hrs Date: Sat Jul 20 16:46:51 2013 New Revision: 253504 URL: http://svnweb.freebsd.org/changeset/base/253504 Log: - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_* as the argument. - Reduce unnecessary loop in print_getmsg(). Modified: head/sbin/route/route.c Hi, This breaks /etc/rc.d/defaultroute, since it relies on route -n get -inet default printing a line with interface: in it. Before r253504 it prints: route to: 0.0.0.0 destination: 0.0.0.0 mask: 56.18.1.0 gateway: router.example.com fib: 0 interface: em0 flags: UP,GATEWAY,DONE,STATIC recvpipe sendpipe ssthresh rtt,msecmtuweightexpire 0 0 0 0 1500 1 0 (note also the mask seems to be busted, and even though -n is given, the hostname of the gateway is printed, but this is another issue) At r253504 it gives: route to: 0.0.0.0 destination: 0.0.0.0 mask: 56.18.1.0 gateway: router.example.com fib: 0 flags: UP,GATEWAY,DONE,STATIC recvpipe sendpipe ssthresh rtt,msecmtuweightexpire 0 0 0 0 1500 1 0 So for some reason, the interface: line is gone.. -Dimitry ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r253504 - head/sbin/route
Dimitry Andric d...@freebsd.org wrote in 36e48152-1a64-432d-a32d-75059a56e...@freebsd.org: di On Jul 20, 2013, at 18:46, Hiroki Sato h...@freebsd.org wrote: di Author: hrs di Date: Sat Jul 20 16:46:51 2013 di New Revision: 253504 di URL: http://svnweb.freebsd.org/changeset/base/253504 di di Log: di - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_* di as the argument. di - Reduce unnecessary loop in print_getmsg(). di di Modified: di head/sbin/route/route.c di di Hi, di di This breaks /etc/rc.d/defaultroute, since it relies on route -n get di -inet default printing a line with interface: in it. Before r253504 di it prints: di diroute to: 0.0.0.0 di destination: 0.0.0.0 dimask: 56.18.1.0 di gateway: router.example.com di fib: 0 di interface: em0 di flags: UP,GATEWAY,DONE,STATIC di recvpipe sendpipe ssthresh rtt,msecmtuweightexpire di0 0 0 0 1500 1 0 di di (note also the mask seems to be busted, and even though -n is given, the di hostname of the gateway is printed, but this is another issue) di di At r253504 it gives: di diroute to: 0.0.0.0 di destination: 0.0.0.0 dimask: 56.18.1.0 di gateway: router.example.com di fib: 0 di flags: UP,GATEWAY,DONE,STATIC di recvpipe sendpipe ssthresh rtt,msecmtuweightexpire di0 0 0 0 1500 1 0 di di So for some reason, the interface: line is gone.. Gr, sorry. This is my fault. I will fix it soon. -- Hiroki pgpS9zCyKzVuT.pgp Description: PGP signature
Re: svn commit: r253504 - head/sbin/route
Dimitry Andric d...@freebsd.org wrote in 36e48152-1a64-432d-a32d-75059a56e...@freebsd.org: di On Jul 20, 2013, at 18:46, Hiroki Sato h...@freebsd.org wrote: di Author: hrs di Date: Sat Jul 20 16:46:51 2013 di New Revision: 253504 di URL: http://svnweb.freebsd.org/changeset/base/253504 di di Log: di - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_* di as the argument. di - Reduce unnecessary loop in print_getmsg(). di di Modified: di head/sbin/route/route.c di di Hi, di di This breaks /etc/rc.d/defaultroute, since it relies on route -n get di -inet default printing a line with interface: in it. Before r253504 di it prints: di diroute to: 0.0.0.0 di destination: 0.0.0.0 dimask: 56.18.1.0 di gateway: router.example.com di fib: 0 di interface: em0 di flags: UP,GATEWAY,DONE,STATIC di recvpipe sendpipe ssthresh rtt,msecmtuweightexpire di0 0 0 0 1500 1 0 di di (note also the mask seems to be busted, and even though -n is given, the di hostname of the gateway is printed, but this is another issue) di di At r253504 it gives: di diroute to: 0.0.0.0 di destination: 0.0.0.0 dimask: 56.18.1.0 di gateway: router.example.com di fib: 0 di flags: UP,GATEWAY,DONE,STATIC di recvpipe sendpipe ssthresh rtt,msecmtuweightexpire di0 0 0 0 1500 1 0 di di So for some reason, the interface: line is gone.. Should be fixed in r253589. Sorry for the breakage. -- Hiroki pgp6wgp4ECYWj.pgp Description: PGP signature
svn commit: r253504 - head/sbin/route
Author: hrs Date: Sat Jul 20 16:46:51 2013 New Revision: 253504 URL: http://svnweb.freebsd.org/changeset/base/253504 Log: - Simplify getaddr() and print_getmsg() by using RTAX_* instead of RTA_* as the argument. - Reduce unnecessary loop in print_getmsg(). Modified: head/sbin/route/route.c Modified: head/sbin/route/route.c == --- head/sbin/route/route.c Sat Jul 20 15:58:43 2013(r253503) +++ head/sbin/route/route.c Sat Jul 20 16:46:51 2013(r253504) @@ -825,35 +825,35 @@ newroute(int argc, char **argv) case K_IFA: if (!--argc) usage(NULL); - getaddr(RTA_IFA, *++argv, 0, nrflags); + getaddr(RTAX_IFA, *++argv, 0, nrflags); break; case K_IFP: if (!--argc) usage(NULL); - getaddr(RTA_IFP, *++argv, 0, nrflags); + getaddr(RTAX_IFP, *++argv, 0, nrflags); break; case K_GENMASK: if (!--argc) usage(NULL); - getaddr(RTA_GENMASK, *++argv, 0, nrflags); + getaddr(RTAX_GENMASK, *++argv, 0, nrflags); break; case K_GATEWAY: if (!--argc) usage(NULL); - getaddr(RTA_GATEWAY, *++argv, 0, nrflags); + getaddr(RTAX_GATEWAY, *++argv, 0, nrflags); gateway = *argv; break; case K_DST: if (!--argc) usage(NULL); - if (getaddr(RTA_DST, *++argv, hp, nrflags)) + if (getaddr(RTAX_DST, *++argv, hp, nrflags)) nrflags |= F_ISHOST; dest = *argv; break; case K_NETMASK: if (!--argc) usage(NULL); - getaddr(RTA_NETMASK, *++argv, 0, nrflags); + getaddr(RTAX_NETMASK, *++argv, 0, nrflags); /* FALLTHROUGH */ case K_NET: nrflags |= F_FORCENET; @@ -888,13 +888,13 @@ newroute(int argc, char **argv) } else { if ((rtm_addrs RTA_DST) == 0) { dest = *argv; - if (getaddr(RTA_DST, *argv, hp, nrflags)) + if (getaddr(RTAX_DST, *argv, hp, nrflags)) nrflags |= F_ISHOST; } else if ((rtm_addrs RTA_GATEWAY) == 0) { gateway = *argv; - getaddr(RTA_GATEWAY, *argv, hp, nrflags); + getaddr(RTAX_GATEWAY, *argv, hp, nrflags); } else { - getaddr(RTA_NETMASK, *argv, 0, nrflags); + getaddr(RTAX_NETMASK, *argv, 0, nrflags); nrflags |= F_FORCENET; } } @@ -1105,7 +1105,7 @@ inet6_makenetandmask(struct sockaddr_in6 * returning 1 if a host address, 0 if a network address. */ static int -getaddr(int which, char *str, struct hostent **hpp, int nrflags) +getaddr(int idx, char *str, struct hostent **hpp, int nrflags) { struct sockaddr *sa; #if defined(INET) @@ -1130,36 +1130,16 @@ getaddr(int which, char *str, struct hos aflen = sizeof(struct sockaddr_dl); #endif } - rtm_addrs |= which; + rtm_addrs |= (1 idx); - switch (which) { - case RTA_DST: - sa = (struct sockaddr *)so[RTAX_DST]; - break; - case RTA_GATEWAY: - sa = (struct sockaddr *)so[RTAX_GATEWAY]; - break; - case RTA_NETMASK: - sa = (struct sockaddr *)so[RTAX_NETMASK]; - break; - case RTA_GENMASK: - sa = (struct sockaddr *)so[RTAX_GENMASK]; - break; - case RTA_IFA: - sa = (struct sockaddr *)so[RTAX_IFA]; - break; - case RTA_IFP: - sa = (struct sockaddr *)so[RTAX_IFP]; - break; - default: + if (idx RTAX_MAX) usage(internal error);