summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-10-08 04:46:59 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-10-08 04:46:59 +0000
commitce98d986b7fff65f4dbc7c7576494e7894278ebf (patch)
treee79b247c6ac92240e6accc2deb40b7646ec7fc39
parentf830ea40c651f82086d7480dbaf34bf39849f3b9 (diff)
Fix off-by-one bug in bitncmp(): When comparing a number of bits divisible by
8, bitncmp() may dereference a pointer one byte out of bounds. Chris Mikkelson (bug #5101)
-rw-r--r--src/backend/utils/adt/network.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c
index dc83d7028c5..b13d3d16e16 100644
--- a/src/backend/utils/adt/network.c
+++ b/src/backend/utils/adt/network.c
@@ -1,7 +1,7 @@
/*
* PostgreSQL type definitions for the INET and CIDR types.
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.54 2004/10/08 01:10:31 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/network.c,v 1.54.4.1 2009/10/08 04:46:59 heikki Exp $
*
* Jon Postel RIP 16 Oct 1998
*/
@@ -899,7 +899,7 @@ bitncmp(void *l, void *r, int n)
b = n / 8;
x = memcmp(l, r, b);
- if (x)
+ if (x || (n % 8) == 0)
return (x);
lb = ((const u_char *) l)[b];