pgsql: Use pg_parse_lsn() for IDENTIFY_SYSTEM responses in libpqwalrece

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use pg_parse_lsn() for IDENTIFY_SYSTEM responses in libpqwalrece
Date: 2026-10-22 07:46:53
Message-ID: E1xJnVl-00000000IcI-1GZR@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use pg_parse_lsn() for IDENTIFY_SYSTEM responses in libpqwalreceiver

libpqwalreceiver parses the WAL flush location returned by
IDENTIFY_SYSTEM using sscanf("%X/%X") into uint32 values. This
accepts overlong components and trailing characters, potentially
producing a different LSN from the one supplied by the upstream server.

Use pg_parse_lsn() instead, requiring one to eight hexadecimal digits
per component and no trailing characters, as for pg_lsn input. Reject
malformed locations with the existing protocol violation error.

Suggested-by: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
Author: Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>
Reviewed-by: Jan Nidzwetzki <jan(at)planetscale(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/tencent_C6ED19DF1759CDD37E786F7EE0B5207D0009@qq.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ba6d9ee259cdb2a6c862a4741b16194106e00a9a

Modified Files
--------------
src/backend/replication/libpqwalreceiver/libpqwalreceiver.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-10-22 08:18:34 pgsql: pg_stat_statements: Add tests for SQL/JSON query patterns
Previous Message Michael Paquier 2026-10-22 05:39:51 pgsql: Fix argument handling in pg_indexam_progress_phasename()