Commit f4f6caa9 authored by Bruce Momjian's avatar Bruce Momjian

Do proper testing of CIDR bits against network mask, e.g. don't allow:

	test=# select '204.248.199.1/31'::cidr;

Previous releases erroneously accepted such addresses.

WARN IN RELEASE NOTES

Kevin Brintnall
parent 050beacc
/* /*
* PostgreSQL type definitions for the INET and CIDR types. * 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 * Jon Postel RIP 16 Oct 1998
*/ */
...@@ -942,7 +942,7 @@ addressOK(unsigned char *a, int bits, int family) ...@@ -942,7 +942,7 @@ addressOK(unsigned char *a, int bits, int family)
if (bits == maxbits) if (bits == maxbits)
return true; return true;
byte = (bits + 7) / 8; byte = bits / 8;
nbits = bits % 8; nbits = bits % 8;
mask = 0xff; mask = 0xff;
if (bits != 0) if (bits != 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment