postgresql/src/backend
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
..
access Add overflow protection for block-related data in WAL records 2022-07-27 13:35:40 +09:00
bootstrap Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
catalog Improve makeArrayTypeName's algorithm for choosing array type names. 2022-07-26 15:38:09 -04:00
commands Fix brain fade in e530be2c5c. 2022-07-26 15:12:09 -04:00
executor Add another SQL/JSON error code 2022-07-18 14:26:43 +02:00
foreign Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
jit Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
lib Fix lock assertions in dshash.c. 2022-07-11 16:43:29 +12:00
libpq Log details for client certificate failures 2022-07-15 17:04:48 +02:00
main Remove support for Visual Studio 2013 2022-07-14 11:22:49 +09:00
nodes Dump more fields when dumping planner internal data structures. 2022-07-20 13:54:30 -04:00
optimizer Remove fls(), use pg_leftmost_one_pos32() instead. 2022-07-22 10:41:50 +12:00
parser Fix a few issues with REINDEX grammar 2022-07-26 10:16:26 +09:00
partitioning Small cleanup of create_list_bounds() 2022-07-13 17:01:01 +12:00
po NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00
port Emulate sigprocmask(), not sigsetmask(), on Windows. 2022-07-16 17:03:38 +12:00
postmaster Reduce overhead of renaming archive status files. 2022-07-26 16:00:18 +09:00
regex Remove redundant null pointer checks before free() 2022-07-03 11:47:15 +02:00
replication Allow users to skip logical replication of data having origin. 2022-07-21 08:47:38 +05:30
rewrite Replace many MemSet calls with struct initialization 2022-07-16 08:50:49 +02:00
snowball Move snowball_create.sql creation into perl file 2022-07-18 12:24:27 -07:00
statistics Invent qsort_interruptible(). 2022-07-12 16:30:36 -04:00
storage Fix ReadRecentBuffer for local buffers. 2022-07-25 08:52:46 +03:00
tcop Force immediate commit after CREATE DATABASE etc in extended protocol. 2022-07-26 13:07:03 -04:00
tsearch Invent qsort_interruptible(). 2022-07-12 16:30:36 -04:00
utils Remove the restriction that the relmap must be 512 bytes. 2022-07-26 14:56:25 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Automatically generate node support functions 2022-07-09 08:53:59 +02:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00