]> granicus.if.org Git - postgresql/commitdiff
Do proper testing of CIDR bits against network mask, e.g. don't allow:
authorBruce Momjian <bruce@momjian.us>
Fri, 8 Oct 2004 01:10:31 +0000 (01:10 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 8 Oct 2004 01:10:31 +0000 (01:10 +0000)
test=# select '204.248.199.1/31'::cidr;

Previous releases erroneously accepted such addresses.

WARN IN RELEASE NOTES

Kevin Brintnall

src/backend/utils/adt/network.c

index ec00f55fe86c1f50a8b25b4e8a8c39badf337480..dc83d7028c5e0367b36902f3ec2bf8bf785f1ee7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     PostgreSQL type definitions for the INET and CIDR types.
  *
- *     $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.53 2004/08/29 05:06:49 momjian Exp $
+ *     $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.54 2004/10/08 01:10:31 momjian Exp $
  *
  *     Jon Postel RIP 16 Oct 1998
  */
@@ -942,7 +942,7 @@ addressOK(unsigned char *a, int bits, int family)
        if (bits == maxbits)
                return true;
 
-       byte = (bits + 7) / 8;
+       byte = bits / 8;
        nbits = bits % 8;
        mask = 0xff;
        if (bits != 0)