From 88d2c8fc8754e31ec2ef85b23a1bcc1aea4b4d85 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Thu, 9 Jan 2014 10:40:36 +0000 Subject: [PATCH] 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 --- sbin/route/route.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sbin/route/route.c b/sbin/route/route.c index 5fad87535b0..2a76932f68c 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