Re: START_REPLICATION silently truncates an overlong LSN component

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: Jan Nidzwetzki <jan(at)planetscale(dot)com>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, ♂π≌26218 <1991230470(at)qq(dot)com>, pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: START_REPLICATION silently truncates an overlong LSN component
Date: 2026-10-22 07:06:51
Message-ID: CAHGQGwEcR5vUL7CFrYSSKAW9Cba9o-b=EsoNjqCU_6iuz+rwTA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Oct 21, 2026 at 6:57 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
> Thanks for the feedback. PSA the fixed version. MAXPG_LSNLEN was also
> exported in the header.

Thanks for updating the patch!

+ if (fscanf(lfp,
+ "CHECKPOINT LOCATION: %" CppAsString2(MAXPG_LSNLEN) "s%c", lsn,
+ &ch) != 2 ||
+ ch != '\n' ||
+ !pg_parse_lsn(lsn, checkPointLoc))

This seems to accept malformed LSN fields such as:

CHECKPOINT LOCATION: 0/123<NUL>junk

Here, <NUL> represents an actual NUL byte. fscanf("%17s") reads past it,
but pg_parse_lsn() sees only 0/123. The old code rejected this because %c
read the NUL instead of a newline. START WAL LOCATION seems to
have the same issue.

BTW, I'm thinking of committing 0001 and 0002 first, as I've reviewed them.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Takeshi Ideriha 2026-10-22 07:46:44 Re: BUG #19760: CLUSTER loses a row the transaction inserted and then updated in a rolled-back subtransaction
Previous Message Kirill Reshke 2026-10-22 05:44:24 Re: Timing issue in pg_basebackup