summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier2025-01-14 06:13:14 +0000
committerMichael Paquier2025-01-14 06:13:14 +0000
commite027ee9902fa414d766c8dc2589c6a3d7aeaa53a (patch)
tree62c15d6f4976f2c5184dcc4e9deecab674d8e929 /src
parentdc24c9ad527fea408ec381208902f2dd412ba9bd (diff)
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 6467bed604a..92cb72ebba6 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -563,7 +563,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
BrinOpaque *opaque;
BlockNumber nblocks;
BlockNumber heapBlk;
- int totalpages = 0;
+ int64 totalpages = 0;
FmgrInfo *consistentFn;
MemoryContext oldcxt;
MemoryContext perRangeCxt;