BUG #5101: Off-by-one error in bitncmp() in src/backend/utils/adt/network.c

From: "Chris Mikkelson" <cmikk(at)qwest(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5101: Off-by-one error in bitncmp() in src/backend/utils/adt/network.c
Date: 2009-10-07 17:47:54
Message-ID: 200910071747.n97HlsvM098115@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5101
Logged by: Chris Mikkelson
Email address: cmikk(at)qwest(dot)net
PostgreSQL version: 8.4.1(+earlier)
Operating system: all
Description: Off-by-one error in bitncmp() in
src/backend/utils/adt/network.c
Details:

When comparing a number of bits divisible by 8, bitncmp() may dereference a
pointer one byte out
of bounds.

The following patch against 8.4.1 incorporates the fix made to bitncmp() in
the BIND source tree:

*** src/backend/utils/adt/network.c.orig 2009-10-07
12:32:13.000000000 -0500
--- src/backend/utils/adt/network.c 2009-10-07 12:32:45.000000000 -0500
*************** bitncmp(void *l, void *r, int n)
*** 972,979 ****

b = n / 8;
x = memcmp(l, r, b);
! if (x)
! return x;

lb = ((const u_char *) l)[b];
rb = ((const u_char *) r)[b];
--- 972,979 ----

b = n / 8;
x = memcmp(l, r, b);
! if (x || (n % 8) == 0)
! return (x);

lb = ((const u_char *) l)[b];
rb = ((const u_char *) r)[b];

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Geoff Tolley 2009-10-07 23:48:23 BUG #5102: Silent IN (list of strings) failure to detect syntax error when list is linewrapped
Previous Message Viet Duc 2009-10-07 04:11:29 BUG #5100: Help me!!I want cause : "invalid page header in block xxxx", i need support to repair and avert