summaryrefslogtreecommitdiffstats
path: root/sbin/route
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2001-07-11 16:11:15 +0000
committerru <ru@FreeBSD.org>2001-07-11 16:11:15 +0000
commit637fad7f2d542998cff5269c64ed76c59591a131 (patch)
treeb36d249a0114f56361c25a0c6a3d119ac8d52945 /sbin/route
parentfd6cdfa2861498bd78b04c36486f2e241207e29d (diff)
downloadFreeBSD-src-637fad7f2d542998cff5269c64ed76c59591a131.zip
FreeBSD-src-637fad7f2d542998cff5269c64ed76c59591a131.tar.gz
Due to the documented bug in inet_aton(3), it wasn't possible
to use 0xffffffff (INADDR_NONE) as a netmask value. The fix is to use inet_addr(3) which doesn't suffer from this problem. PR: bin/28873 Also, while here, fixed the bug when netmask value was ignored (RTF_HOST flag was set) if the "destination gateway netmask" syntax is used, e.g. ``route add 1.2.3.4 127.1 255.255.255.255''.
Diffstat (limited to 'sbin/route')
-rw-r--r--sbin/route/route.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 38c35f7..6501854 100644
--- a/sbin/route/route.c
+++ b/sbin/route/route.c
@@ -736,6 +736,7 @@ newroute(argc, argv)
(void) getaddr(RTA_GATEWAY, *argv, &hp);
} else {
(void) getaddr(RTA_NETMASK, *argv, 0);
+ forcenet = 1;
}
}
}
@@ -1030,8 +1031,8 @@ getaddr(which, s, hpp)
*q = '/';
}
if ((which != RTA_DST || forcenet == 0) &&
- (val = inet_addr(s)) != INADDR_NONE) {
- su->sin.sin_addr.s_addr = val;
+ inet_aton(s, &su->sin.sin_addr)) {
+ val = su->sin.sin_addr.s_addr;
if (which != RTA_DST ||
inet_lnaof(su->sin.sin_addr) != INADDR_ANY)
return (1);
OpenPOWER on IntegriCloud