Re: BUG #18828: Crash when pg_get_logical_snapshot_meta() passed empty string

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, tharakan@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2025-03-06T06:42:35Z
Lists: pgsql-bugs

Attachments

On Tue, Mar 4, 2025 at 10:44 PM Bertrand Drouvot
<bertranddrouvot.pg@gmail.com> wrote:
>
> Hi,
>
> On Tue, Mar 04, 2025 at 09:45:54PM +0000, Bertrand Drouvot wrote:
> > Indeed, thanks for looking at it! Fixed in v4 attached. Note that the pfree()
> > in parse_snapshot_filename() is not needed per say because the function is
> > currently executed in a short-lived memory context. It's there for safety reason
> > in case it's called outside those SQL apis in the future.
>
> After sleeping on it, PFA a simplified version.
>

Thank you for updating the patch.

I think we don't need to even do palloc() for the buffer as we can use
the char[MAXPGPATH] instead. I've attached the patch to improve the
parse_snapshot_filename() function and add some regression tests.
Please review these changes.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pg_logicalinspect: Fix possible crash when passing a directory path.

  2. Add contrib/pg_logicalinspect.

  3. Fix compiler warning on Windows.