8000 Add assertion to check the special size is sane before dereferencing it. · postgrespro/postgres@302ac7f · GitHub
[go: up one dir, main page]

Skip to content < 8000 link crossorigin="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/keyboard-shortcuts-dialog.f8fba3bd67fe74f9227b.module.css" />

Commit 302ac7f

Browse files
committed
Add assertion to check the special size is sane before dereferencing it.
This seems useful to catch errors of the sort I just fixed, where PageGetSpecialPointer is called before initializing the page.
1 parent fdf2885 commit 302ac7f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/include/storage/bufpage.h

Lines changed: 2 additions & 0 deletions
< 3735 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ typedef PageHeaderData *PageHeader;
304304
#define PageGetSpecialPointer(page) \
305305
( \
306306
AssertMacro(PageIsValid(page)), \
307+
AssertMacro(((PageHeader) (page))->pd_special <= BLCKSZ), \
308+
AssertMacro(((PageHeader) (page))->pd_special >= SizeOfPageHeaderData), \
307309
(char *) ((char *) (page) + ((PageHeader) (page))->pd_special) \
308310
)
309311

0 commit comments

Comments
 (0)
0