pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Reject overlong LSN components in START_REPLICATION
Date: Thu, 22 Oct 2026 07:46:53 +0000
Message-ID: <E1xJnVl-00000000IcG-19rz@gemulon.postgresql.org> (raw)

Reject overlong LSN components in START_REPLICATION

The replication command scanner accepts arbitrarily long hexadecimal
LSN components, but converts them with sscanf("%X/%08X") into uint32
values. An overlong high component can overflow, while an overlong low
component is truncated to its first eight digits. This can cause
START_REPLICATION to use a different WAL location from the one requested.

Use pg_parse_lsn() to validate and convert the complete LSN token,
requiring one to eight hexadecimal digits per component, as for pg_lsn
input. This applies to both physical and logical replication.

Reported-by: ♂π≌26218 <1991230470@qq.com>
Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Jan Nidzwetzki <jan@planetscale.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4a842a1d6570b0875fb705e6335a16b525cbbd79

Modified Files
--------------
src/backend/replication/repl_scanner.l      |  6 ++----
src/test/recovery/t/006_logical_decoding.pl | 12 ++++++++++++
2 files changed, 14 insertions(+), 4 deletions(-)



Message-ID: <E1xJnVl-00000000IcG-19rz@gemulon.postgresql.org>
Permalink:  ../E1xJnVl-00000000IcG-19rz@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xJnVl-00000000IcG-19rz@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: fujii@postgresql.org
  Subject: Re: pgsql: Reject overlong LSN components in START_REPLICATION
  In-Reply-To: <E1xJnVl-00000000IcG-19rz@gemulon.postgresql.org>
  References: <E1xJnVl-00000000IcG-19rz@gemulon.postgresql.org>

* 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