aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2014-01-09 10:40:36 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2014-01-09 10:40:36 +0000
commit88d2c8fc8754e31ec2ef85b23a1bcc1aea4b4d85 (patch)
treedafc21e92d66f03f711c84601f7bcd02b62330a8 /sbin
parent796aef8d174304cada696be47670322e7702f2be (diff)
downloadsrc-88d2c8fc8754e31ec2ef85b23a1bcc1aea4b4d85.tar.gz
src-88d2c8fc8754e31ec2ef85b23a1bcc1aea4b4d85.zip
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
Notes
Notes: svn path=/head/; revision=260472
Diffstat (limited to 'sbin')
-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 5fad87535b05..2a76932f68cc 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -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