Re: BUG #19598: pg_waldump: -s/-e accept out-of-range WAL locations and silently use the low 32 bits

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Zexin Li <lizi(dot)openmind(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org, malis(at)pgrust(dot)com
Subject: Re: BUG #19598: pg_waldump: -s/-e accept out-of-range WAL locations and silently use the low 32 bits
Date: 2026-08-10 08:23:21
Message-ID: CAJTYsWWHNwUEDWT+wUu-BUY0Md2UFQ_JQK-kLTtfkx5PtHdiFg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Mon, 10 Aug 2026 at 11:17, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:

> On Fri, Aug 7, 2026 at 10:58 AM Zexin Li <lizi(dot)openmind(at)gmail(dot)com> wrote:
> > The helper is pg_parse_lsn() in the new src/common/pg_parse_lsn.c,
> > with the same rules as the backend's pg_lsn_in_safe(): one to eight
> > hex digits, a slash, one to eight hex digits, and nothing else.
> > pg_waldump's static helper from v1 moves there, and pg_recvlogical
> > (-I/-E) and pg_receivewal (-E) now go through it as well.
>
> > * The backend's pg_lsn_in_safe() is left untouched for now.
>
> Thanks for updating the patch!
>
> Attached is a revised version. It keeps the v2 approach of adding
> pg_parse_lsn() in src/common and using it for user-supplied LSN
> command-line options in pg_waldump, pg_recvlogical, and
> pg_receivewal.
>
> The main change from v2 is that pg_lsn_in_safe() now also uses
> pg_parse_lsn(), leaving only the backend-specific soft-error handling
> there. This avoids duplicating the LSN syntax checks.
>
> Thought?

I reviewed v3, and it looks good to me.
In parallel, I had reported and patched the same sscanf("%X/%08X")
issue in src/common/parse_manifest.c [0]

Once this is committed, I'll rebase that patch onto it and post a new
version on the earlier thread.

Regards,
Ayush

[0]
https://www.postgresql.org/message-id/CAJTYsWXieRHb-ooV2XfjHAtBsS7%2BP5La_-o8-Cqi15CNDhh9hQ%40mail.gmail.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kirill Reshke 2026-08-10 11:41:23 Re: REVOKE's CASCADE protection doesn't work with INHERITed table owners
Previous Message Fujii Masao 2026-08-10 05:47:39 Re: BUG #19598: pg_waldump: -s/-e accept out-of-range WAL locations and silently use the low 32 bits