summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-03-27 18:59:57 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-03-27 18:59:57 +0000
commita583bb1dd0b25dc0951f21af2bf048e63e98d26e (patch)
tree4adabf1232ae19322b3984d65d68dfd9169439dd
parent29b54561850f808bbf75d08979c2b0a109d8b723 (diff)
Fix bug (I introduced) with aliases and in_broadcast().
-rw-r--r--sys/netinet/in.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 5da03f4e951..620f6372341 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.c,v 1.10 1998/03/20 02:45:06 deraadt Exp $ */
+/* $OpenBSD: in.c,v 1.11 1998/03/27 18:59:56 angelos Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
@@ -467,21 +467,34 @@ in_broadcast(in, ifp)
/*
* Look through the list of addresses for a match
* with a broadcast address.
- * If ifp is NULL, check against all the local interfaces.
+ * If ifp is NULL, check against all the interfaces.
*/
for (ifn = if_first; ifn != if_target; ifn = ifn->if_list.tqe_next)
for (ifa = ifn->if_addrlist.tqh_first; ifa;
ifa = ifa->ifa_list.tqe_next)
- if (ifa->ifa_addr->sa_family == AF_INET &&
- (((in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
- in.s_addr == ia->ia_netbroadcast.s_addr) &&
- (ia->ia_subnetmask != 0xffffffff)) ||
- /*
- * Check for old-style (host 0) broadcast.
- */
- in.s_addr == ia->ia_subnet ||
- in.s_addr == ia->ia_net))
- return 1;
+ if (!ifp)
+ {
+ if (ifa->ifa_addr->sa_family == AF_INET &&
+ ((ia->ia_subnetmask != 0xffffffff &&
+ (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
+ in.s_addr == ia->ia_subnet)) ||
+ /*
+ * Check for old-style (host 0) broadcast.
+ */
+ (in.s_addr == ia->ia_netbroadcast.s_addr ||
+ in.s_addr == ia->ia_net)))
+ return 1;
+ }
+ else
+ if (ifa->ifa_addr->sa_family == AF_INET &&
+ (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
+ in.s_addr == ia->ia_netbroadcast.s_addr ||
+ /*
+ * Check for old-style (host 0) broadcast.
+ */
+ in.s_addr == ia->ia_subnet ||
+ in.s_addr == ia->ia_net))
+ return 1;
return (0);
#undef ia
}