summaryrefslogtreecommitdiff
path: root/src/include/access/xloginsert.h
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2022-07-27 13:35:40 +0900
committerMichael Paquier <michael@paquier.xyz>2022-07-27 13:35:40 +0900
commitffd1b6bb6f8a2ffc929699772610c6925364dbb3 (patch)
tree79d1218236c71707fc407c8c853839826cb75a48 /src/include/access/xloginsert.h
parent70988b7b0a0bd03c59a2314d0b5bcf2135692349 (diff)
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
Diffstat (limited to 'src/include/access/xloginsert.h')
-rw-r--r--src/include/access/xloginsert.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/access/xloginsert.h b/src/include/access/xloginsert.h
index c04f77b173a..aed4643d1c5 100644
--- a/src/include/access/xloginsert.h
+++ b/src/include/access/xloginsert.h
@@ -43,12 +43,12 @@ extern void XLogBeginInsert(void);
extern void XLogSetRecordFlags(uint8 flags);
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info);
extern void XLogEnsureRecordSpace(int max_block_id, int ndatas);
-extern void XLogRegisterData(char *data, int len);
+extern void XLogRegisterData(char *data, uint32 len);
extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags);
extern void XLogRegisterBlock(uint8 block_id, RelFileLocator *rlocator,
ForkNumber forknum, BlockNumber blknum, char *page,
uint8 flags);
-extern void XLogRegisterBufData(uint8 block_id, char *data, int len);
+extern void XLogRegisterBufData(uint8 block_id, char *data, uint32 len);
extern void XLogResetInsertion(void);
extern bool XLogCheckBufferNeedsBackup(Buffer buffer);