Re: Fw: Re: heap_force_common in contrib/pg_surgery/heap_surgery.c has an off by one stack buffer overflow

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Ashutosh Sharma <ashu.coek88@gmail.com>
Cc: surya poondla <suryapoondla4@gmail.com>, "violin0613@tju.edu.cn" <violin0613@tju.edu.cn>, pgsql-bugs@postgresql.org
Date: 2026-06-05T06:57:06Z
Lists: pgsql-bugs

Attachments

On Fri, Jun 05, 2026 at 08:17:15AM +0900, Michael Paquier wrote:
> At the end, the first pattern is an outlier, we don't need to worry
> about performance in pg_surgery, and we're talking about three lines
> of code in pg_surgery to change (two for include_this_tid, one for the
> assertion).  With all that in mind, I'd just do a -1 conversion and
> call it a day.  :)

Which implies something like the simpler patch attached.
--
Michael

Commits

  1. pg_surgery: Fix off-by-one bug with heap offset