pgsql: pg_surgery: Fix off-by-one bug with heap offset - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: pg_surgery: Fix off-by-one bug with heap offset
Date
Msg-id E1wVdn5-001G3u-0M@gemulon.postgresql.org
Whole thread
List pgsql-committers
pg_surgery: Fix off-by-one bug with heap offset

heap_force_common() declared a boolean array indexed with an
OffsetNumber for a size of MaxHeapTuplesPerPage.  OffsetNumbers are
1-based, so an input TID whose offset number equals MaxHeapTuplesPerPage
wrote one byte past the end of the stack array, crashing the server.

Like heapam_handler.c, this commit changes the array so as it uses a
0-based index, substracting one from the OffsetNumbers.

Reported-by: Wang Yuelin <violin0613@tju.edu.cn>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Discussion: https://postgr.es/m/20260604002256.40f1fd544@smtp.qiye.163.com
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b09f8a9110a5de217fa59dfb3215686def7dc36

Modified Files
--------------
contrib/pg_surgery/heap_surgery.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)


pgsql-committers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: pgsql: doc: Clarify OAuth validator authn_id logging
Next
From: Michael Paquier
Date:
Subject: pgsql: Lift shutdown assertion in pgstats for WAL senders