aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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