pgsql: pg_controldata: Fix possible errors on corrupted pg_control

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_controldata: Fix possible errors on corrupted pg_control
Date: 2025-02-04 22:46:56
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_controldata: Fix possible errors on corrupted pg_control

Protect against malformed timestamps. Also protect against negative WalSegSz
as it triggers division by zero:

((0x100000000UL) / (WalSegSz)) can turn into zero in

XLogFileName(xlogfilename, ControlFile->checkPointCopy.ThisTimeLineID,
segno, WalSegSz);

because if WalSegSz is -1 then by arithmetic rules in C we get
0x100000000UL / 0xFFFFFFFFFFFFFFFFUL == 0.

Author: Ilyasov Ian <ianilyasov(at)outlook(dot)com>
Author: Anton Voloshin <a(dot)voloshin(at)postgrespro(dot)ru>
Backpatch-through: 13

Branch
------
REL_14_STABLE

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

Modified Files
--------------
src/bin/pg_controldata/pg_controldata.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alexander Korotkov 2025-02-04 22:46:58 pgsql: pg_controldata: Fix possible errors on corrupted pg_control
Previous Message Alexander Korotkov 2025-02-04 22:46:38 pgsql: pg_controldata: Fix possible errors on corrupted pg_control