pgsql: Initialize padding bytes in btree_gist varbit support.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Initialize padding bytes in btree_gist varbit support.
Date: 2014-05-13 12:32:06
Message-ID: E1WkBsM-0004kP-Jg@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Initialize padding bytes in btree_gist varbit support.

The code expands a varbit gist leaf key to a node key by copying the bit
data twice in a varlen datum, as both the lower and upper key. The lower key
was expanded to INTALIGN size, but the padding bytes were not initialized.
That's a problem because when the lower/upper keys are compared, the padding
bytes are used compared too, when the values are otherwise equal. That could
lead to incorrect query results.

REINDEX is advised for any btree_gist indexes on bit or bit varying data
type, to fix any garbage padding bytes on disk.

Per Valgrind, reported by Andres Freund. Backpatch to all supported
versions.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0d8d0d027723d4470a9e2571c499752aa6d8df7a

Modified Files
--------------
contrib/btree_gist/btree_bit.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-05-13 16:19:58 pgsql: Fix harmless access to uninitialized memory.
Previous Message Noah Misch 2014-05-13 03:05:37 pgsql: Add Valgrind suppression for reorderbuffer padding bytes.