1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-12 15:23:02 +03:00

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)
This commit is contained in:
Heikki Linnakangas
2009-10-08 04:46:59 +00:00
parent f830ea40c6
commit ce98d986b7

View File

@@ -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];