From: Chao Li <li.evan.chao@gmail.com>
To: Haibo Yan <tristan.yim@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: [PATCH v1] pg_stash_advice: Reject embedded NUL bytes in persistence files
Date: Tue, 17 Nov 2026 15:25:25 +0800
Message-ID: <7010C1D7-7ADD-40F2-B00E-47074CA4F8CA@gmail.com> (raw)
In-Reply-To: <CABXr29FCkRXumwV1sFvbZd_uEw5A4Jg_oDVnWgLjgRN6esUHTA@mail.gmail.com>
References: <CABXr29FCkRXumwV1sFvbZd_uEw5A4Jg_oDVnWgLjgRN6esUHTA@mail.gmail.com>
> On Nov 17, 2026, at 10:35, Haibo Yan <tristan.yim@gmail.com> wrote:
>
> Hi hackers,
>
> The initial leads for this work came from several independent
> LLM-assisted reviews of the plan advice code. The reviews identified
> several candidate issues, which we then reproduced and checked
> individually. Several issues were confirmed.
>
> This is the first patch we are posting from that review. It addresses
> one of the confirmed issues. The remaining fixes are independent and
> will be submitted separately after their tests and reviews are
> complete.
>
> pg_stash_advice reads its persistence file into memory, but the loader
> previously parsed the buffer as a NUL-terminated string. If the file
> contained an embedded NUL byte, the loader silently treated it as the
> end of the file and accepted only the preceding records.
Hi Haibo,
Thanks for the patch.
I'm just curious why a file might contain an embedded NUL byte. Is there a known scenario where pg_stash_advice.tsv could contain a NUL byte? If that's because of file corruption, couldn't any byte appear in the middle of the file? In that case, is checking only for NUL bytes good enough?
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: li.evan.chao@gmail.com, tristan.yim@gmail.com, robertmhaas@gmail.com
Subject: Re: [PATCH v1] pg_stash_advice: Reject embedded NUL bytes in persistence files
In-Reply-To: <7010C1D7-7ADD-40F2-B00E-47074CA4F8CA@gmail.com>
References: <CABXr29FCkRXumwV1sFvbZd_uEw5A4Jg_oDVnWgLjgRN6esUHTA@mail.gmail.com> <7010C1D7-7ADD-40F2-B00E-47074CA4F8CA@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox