pgsql: Use pg_parse_lsn() to parse LSN fields in backup_label

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use pg_parse_lsn() to parse LSN fields in backup_label
Date: 2026-10-29 11:46:36
Message-ID: E1xMOaa-00000001Fm8-3f45@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use pg_parse_lsn() to parse LSN fields in backup_label

The START WAL LOCATION and CHECKPOINT LOCATION fields in backup_label
accepted overlong high components, which could overflow and produce a
different LSN from the one supplied.

Use pg_parse_lsn() to validate and convert these fields, requiring one
to eight hexadecimal digits per component and no trailing characters,
as for pg_lsn input.

Also detect INCREMENTAL FROM LSN without parsing its value, so that
malformed values such as "junk" do not bypass the existing check
against using an incremental backup directly as a data directory.

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/OS7PR01MB18317EED85B1A72C69B226630F5672@OS7PR01MB18317.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/76a55702d89ba9f5d0198c2d5d3d2d62357a8880

Modified Files
--------------
src/backend/access/transam/xlogrecovery.c | 27 ++++++++++++++++++---------
src/backend/utils/adt/pg_lsn.c | 2 --
src/include/common/pg_parse_lsn.h | 2 ++
3 files changed, 20 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Previous Message Michael Paquier 2026-10-29 08:11:26 Re: pgsql: Set HEAP_XMAX_INVALID for tuples updated by aborted subtransacti