aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-01-14 15:13:17 +0900
committerMichael Paquier <michael@paquier.xyz>2025-01-14 15:13:17 +0900
commit9e9f30139eb87e30be64dc34fad6a01e029e8a56 (patch)
treecf6ee199e0b6c2360b53f05c3e1c19d7138e1da3 /src
parent9ad7a32b2a151a7052016e55acdeb20247acefdd (diff)
downloadpostgresql-9e9f30139eb87e30be64dc34fad6a01e029e8a56.tar.gz
postgresql-9e9f30139eb87e30be64dc34fad6a01e029e8a56.zip
Fix potential integer overflow in bringetbitmap()
This function expects an "int64" as result and stores the number of pages to add to the index scan bitmap as an "int", multiplying its final result by 10. For a relation large enough, this can theoretically overflow if counting more than (INT32_MAX / 10) pages, knowing that the number of pages is upper-bounded by MaxBlockNumber. To avoid the overflow, this commit redefines "totalpages", used to calculate the result, to be an "int64" rather than an "int". Reported-by: Evgeniy Gorbanyov Author: James Hunter Discussion: https://www.postgresql.org/message-id/07704817-6fa0-460c-b1cf-cd18f7647041@basealt.ru Backpatch-through: 13
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/brin/brin.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index a38ff1b4fd2..d3b5f349a24 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -361,7 +361,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
BrinOpaque *opaque;
BlockNumber nblocks;
BlockNumber heapBlk;
- int totalpages = 0;
+ int64 totalpages = 0;
FmgrInfo *consistentFn;
MemoryContext oldcxt;
MemoryContext perRangeCxt;