summaryrefslogtreecommitdiffstats
path: root/sbin/route
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-12-04 20:05:01 +0000
committerglebius <glebius@FreeBSD.org>2012-12-04 20:05:01 +0000
commite3194b87ca5c4f35638ebd27dfe4f3c8a2344e58 (patch)
tree0086aeb08a19e81ff260bf0d6ff0689787344fb2 /sbin/route
parentdb5359d69a9ec06842730b8af2a30072a38b5aa1 (diff)
downloadFreeBSD-src-e3194b87ca5c4f35638ebd27dfe4f3c8a2344e58.zip
FreeBSD-src-e3194b87ca5c4f35638ebd27dfe4f3c8a2344e58.tar.gz
Fix fallout from r243019, which broke parsing of shortened network
prefixes. Reported and tested by: delphij
Diffstat (limited to 'sbin/route')
-rw-r--r--sbin/route/route.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index b63ce63..809dc9f 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -1033,6 +1033,13 @@ inet_makenetandmask(u_long net, struct sockaddr_in *sin, u_long bits)
rtm_addrs |= RTA_NETMASK;
/*
+ * MSB of net should be meaningful. 0/0 is exception.
+ */
+ if (net > 0)
+ while ((net & 0xff000000) == 0)
+ net <<= 8;
+
+ /*
* If no /xx was specified we must calculate the
* CIDR address.
*/
OpenPOWER on IntegriCloud