diff options
author | melifaro <melifaro@FreeBSD.org> | 2014-01-09 10:40:36 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2014-01-09 10:40:36 +0000 |
commit | 144cc340ac778922342569b0c6650556978a2b35 (patch) | |
tree | dafc21e92d66f03f711c84601f7bcd02b62330a8 /sbin | |
parent | efe626246bec4643d3b7813f372c733a071e5240 (diff) | |
download | FreeBSD-src-144cc340ac778922342569b0c6650556978a2b35.zip FreeBSD-src-144cc340ac778922342569b0c6650556978a2b35.tar.gz |
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
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/route/route.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index 5fad875..2a76932 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 |