]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix edge-case for xl_tot_len broken by bae868ca.
authorThomas Munro <tmunro@postgresql.org>
Mon, 25 Sep 2023 20:07:26 +0000 (09:07 +1300)
committerThomas Munro <tmunro@postgresql.org>
Mon, 25 Sep 2023 21:54:02 +0000 (10:54 +1300)
commit99d334a187ae5c283aca1c31b9fad0cea140a4b2
tree0aa0ebd1ce8bbc9358bb4dc302e12b6d90368822
parent9dc3c5472ed99a1046a4d7884270a35cfad29d1d
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@sss.pgh.pa.us>
Tested-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGLCkTT7zYjzOxuLGahBdQ%3DMcF%3Dz5ZvrjSOnW4EDhVjT-g%40mail.gmail.com
src/backend/access/transam/xlogreader.c
src/test/recovery/t/039_end_of_wal.pl