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

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, tharakan(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18828: Crash when pg_get_logical_snapshot_meta() passed empty string
Date: 2025-03-06 06:42:35
Message-ID: CAD21AoBVnenMbN4qccEmCOE9H=_Z1PUaPMBf0HPjK4E9W7z3gw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Mar 4, 2025 at 10:44 PM Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)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

Attachment Content-Type Size
improve_parse_snapshot_filename.patch application/octet-stream 3.9 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robins Tharakan 2025-03-06 07:20:59 Re: BUG #18828: Crash when pg_get_logical_snapshot_meta() passed empty string
Previous Message PG Bug reporting form 2025-03-06 01:16:57 BUG #18832: Segfault in GrantLockLocal