pgsql: pg_controldata: Fix possible errors on corrupted pg_control - Mailing list pgsql-committers

From Alexander Korotkov
Subject pgsql: pg_controldata: Fix possible errors on corrupted pg_control
Date
Msg-id E1tfRh6-005P5X-66@gemulon.postgresql.org
Whole thread Raw
List 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@outlook.com>
Author: Anton Voloshin <a.voloshin@postgrespro.ru>
Backpatch-through: 13

Branch
------
REL_16_STABLE

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

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


pgsql-committers by date:

Previous
From: Alexander Korotkov
Date:
Subject: pgsql: pg_controldata: Fix possible errors on corrupted pg_control
Next
From: Alexander Korotkov
Date:
Subject: pgsql: pg_controldata: Fix possible errors on corrupted pg_control