From 6d2d67a63eccdcd071066cc14cce0215ddfcb042 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 24 Aug 2004 02:57:34 +0000 Subject: revert. itojun notes that 128 is ok because of bitlen check. add a comment to this effect since many of us were confused. ok deraadt@ --- sys/netinet6/in6.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 10373057a37..0d02c07eae9 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.58 2004/08/21 06:57:50 tedu Exp $ */ +/* $OpenBSD: in6.c,v 1.59 2004/08/24 02:57:33 tedu Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -2190,7 +2190,7 @@ in6_are_prefix_equal(p1, p2, len) int bytelen, bitlen; /* sanity check */ - if (0 > len || len >= 128) { + if (0 > len || len > 128) { log(LOG_ERR, "in6_are_prefix_equal: invalid prefix length(%d)\n", len); return (0); @@ -2201,6 +2201,7 @@ in6_are_prefix_equal(p1, p2, len) if (bcmp(&p1->s6_addr, &p2->s6_addr, bytelen)) return (0); + /* len == 128 is ok because bitlen == 0 then */ if (bitlen != 0 && p1->s6_addr[bytelen] >> (8 - bitlen) != p2->s6_addr[bytelen] >> (8 - bitlen)) @@ -2218,7 +2219,7 @@ in6_prefixlen2mask(maskp, len) int bytelen, bitlen, i; /* sanity check */ - if (0 > len || len >= 128) { + if (0 > len || len > 128) { log(LOG_ERR, "in6_prefixlen2mask: invalid prefix length(%d)\n", len); return; @@ -2229,6 +2230,7 @@ in6_prefixlen2mask(maskp, len) bitlen = len % 8; for (i = 0; i < bytelen; i++) maskp->s6_addr[i] = 0xff; + /* len == 128 is ok because bitlen == 0 then */ if (bitlen) maskp->s6_addr[bytelen] = maskarray[bitlen - 1]; } -- cgit v1.2.3