diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2005-06-16 18:43:08 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2005-06-16 18:43:08 +0000 |
commit | c199f848fd9ee5bdebd8c68028cab2d80a10deff (patch) | |
tree | 3149a4281d6e595cbb23b1aba972bc50b7bfc339 /usr.sbin/bgpd/session.c | |
parent | 332823dcdc4b0731c36d6f4a6ea4740ca1f77ae7 (diff) |
use prefixlen2mask() instead of doing the bitshifting by hand; fixes the
zero prefixlen case (32 bit shift on 32 bit val -> undefined result)
spotted by Moritz Grimm and otto
Diffstat (limited to 'usr.sbin/bgpd/session.c')
-rw-r--r-- | usr.sbin/bgpd/session.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 80fed08f770..54208f3a99e 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.227 2005/06/09 12:31:38 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.228 2005/06/16 18:43:07 henning Exp $ */ /* * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> @@ -2518,7 +2518,7 @@ session_match_mask(struct peer *p, struct sockaddr *ip) struct in6_addr mask; if (p->conf.remote_addr.af == AF_INET) { - v4mask = htonl(0xffffffff << (32 - p->conf.remote_masklen)); + v4mask = htonl(prefixlen2mask(p->conf.remote_masklen)); if (p->conf.remote_addr.v4.s_addr == ((((struct sockaddr_in *)ip)->sin_addr.s_addr) & v4mask)) return (1); |