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
This commit is contained in:
Alexander V. Chernikov 2014-01-09 10:40:36 +00:00
parent 796aef8d17
commit 88d2c8fc87
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=260472

View File

@ -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