svn commit: r260472 - head/sbin/route

Alexander V. Chernikov melifaro at FreeBSD.org
Thu Jan 9 10:40:37 UTC 2014


Author: melifaro
Date: Thu Jan  9 10:40:36 2014
New Revision: 260472
URL: http://svnweb.freebsd.org/changeset/base/260472

Log:
  Do some more sanity checks in route(8): require netmask to have
  the same address family as destination.
  
  Found by:	jmg
  MFC after:	2 weeks

Modified:
  head/sbin/route/route.c

Modified: head/sbin/route/route.c
==============================================================================
--- head/sbin/route/route.c	Thu Jan  9 09:19:59 2014	(r260471)
+++ head/sbin/route/route.c	Thu Jan  9 10:40:36 2014	(r260472)
@@ -958,11 +958,18 @@ newroute(int argc, char **argv)
 		}
 	}
 
+	/* Do some sanity checks on resulting request */
 	if (so[RTAX_DST].ss_len == 0) {
 		warnx("destination parameter required");
 		usage(NULL);
 	}
 
+	if (so[RTAX_NETMASK].ss_len != 0 &&
+	    so[RTAX_DST].ss_family != so[RTAX_NETMASK].ss_family) {
+		warnx("destination and netmask family need to be the same");
+		usage(NULL);
+	}
+
 	if (nrflags & F_FORCEHOST) {
 		nrflags |= F_ISHOST;
 #ifdef INET6


More information about the svn-src-all mailing list