aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-06-30 13:44:04 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-06-30 13:44:04 +0300
commit302ac7f27197855afa8c89fae36c85c124ae156b (patch)
treec92ac6a9decee614a2dc58bd2a1bd4721f35f35b /src
parentfdf28853ae6a397497b79fea69f89f4f7b9aa991 (diff)
downloadpostgresql-302ac7f27197855afa8c89fae36c85c124ae156b.tar.gz
postgresql-302ac7f27197855afa8c89fae36c85c124ae156b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/include/storage/bufpage.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h
index c2fbffc8e9b..a2f78ee56ce 100644
--- a/src/include/storage/bufpage.h
+++ b/src/include/storage/bufpage.h
@@ -304,6 +304,8 @@ typedef PageHeaderData *PageHeader;
#define PageGetSpecialPointer(page) \
( \
AssertMacro(PageIsValid(page)), \
+ AssertMacro(((PageHeader) (page))->pd_special <= BLCKSZ), \
+ AssertMacro(((PageHeader) (page))->pd_special >= SizeOfPageHeaderData), \
(char *) ((char *) (page) + ((PageHeader) (page))->pd_special) \
)