pgsql: Fix edge-case for xl_tot_len broken by bae868ca.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix edge-case for xl_tot_len broken by bae868ca.
Date: 2023-09-25 22:12:57
Message-ID: E1qktp3-005wi7-01@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix edge-case for xl_tot_len broken by bae868ca.

bae868ca removed a check that was still needed. If you had an
xl_tot_len at the end of a page that was too small for a record header,
but not big enough to span onto the next page, we'd immediately perform
the CRC check using a bogus large length. Because of arbitrary coding
differences between the CRC implementations on different platforms,
nothing very bad happened on common modern systems. On systems using
the _sb8.c fallback we could segfault.

Restore that check, add a new assertion and supply a test for that case.
Back-patch to 12, like bae868ca.

Tested-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Tested-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA%2BhUKGLCkTT7zYjzOxuLGahBdQ%3DMcF%3Dz5ZvrjSOnW4EDhVjT-g%40mail.gmail.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3d413c5a76fab4e374960ba6929545469c44aa13

Modified Files
--------------
src/backend/access/transam/xlogreader.c | 11 +++++++++++
src/test/recovery/t/039_end_of_wal.pl | 13 +++++++++++++
2 files changed, 24 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2023-09-25 22:13:09 pgsql: Fix edge-case for xl_tot_len broken by bae868ca.
Previous Message Thomas Munro 2023-09-25 22:12:46 pgsql: Fix edge-case for xl_tot_len broken by bae868ca.