postgresql/src
Michael Paquier ffd1b6bb6f Add overflow protection for block-related data in WAL records
XLogRecordBlockHeader, the header holding the information for the data
related to a block, tracks the length of the data appended to the WAL
record with data_length (uint16).  This limitation in size was not
enforced by the public routine in charge of registering the data
assembled later to form the WAL record inserted, XLogRegisterBufData().
Incorrectly used, it could lead to the generation of records with some
of its data overflowed.  This commit adds some safeguards to prevent
that for the block data, complaining immediately if attempting to add to
a record block information with a size larger than UINT16_MAX, which is
the limit implied by the internal logic.

Note that this also adjusts XLogRegisterData() and XLogRegisterBufData()
so as the length of the WAL record data given by the caller is unsigned,
matching with what gets stored in XLogRecData->len.

Extracted from a larger patch by the same author.  The original patch
includes more protections when assembling a record in full that will be
looked at separately later.

Author: Matthias van de Meent
Reviewed-by: Andres Freund, Heikki Linnakangas, Michael Paquier, David
Zhang
Discussion: https://postgr.es/m/CAEze2WgGiw+LZt+vHf8tWqB_6VxeLsMeoAuod0N=ij1q17n5pw@mail.gmail.com
2022-07-27 13:35:40 +09:00
..
backend Add overflow protection for block-related data in WAL records 2022-07-27 13:35:40 +09:00
bin Fix a few issues with REINDEX grammar 2022-07-26 10:16:26 +09:00
common Add output directory argument to generate-unicode_norm_table.pl 2022-07-18 12:24:39 -07:00
fe_utils Add xheader_width pset option to psql 2022-07-25 14:25:02 -04:00
include Add overflow protection for block-related data in WAL records 2022-07-27 13:35:40 +09:00
interfaces Fix [install]check in interfaces/libpq/Makefile 2022-07-22 20:15:11 +02:00
makefiles Default to hidden visibility for extension libraries where possible 2022-07-17 17:49:51 -07:00
pl Add PGDLLEXPORTS to some plpgsql function declarations 2022-07-20 10:24:50 +02:00
port Remove dead getpwuid_r replacement code. 2022-07-24 09:44:29 +12:00
template Remove HP-UX port. 2022-07-08 14:05:05 +12:00
test Improve makeArrayTypeName's algorithm for choosing array type names. 2022-07-26 15:38:09 -04:00
timezone Update time zone data files to tzdata release 2022a. 2022-05-05 14:54:53 -04:00
tools Add xheader_width pset option to psql 2022-07-25 14:25:02 -04:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Increase minimum supported GNU make version to 3.81. 2022-07-23 12:12:42 -04:00
Makefile.shlib Default to hidden visibility for extension libraries where possible 2022-07-17 17:49:51 -07:00
nls-global.mk Fix for make unportability 2022-07-13 09:15:01 +02:00