Skip to content

Commit 720e529

Browse files
committedJan 14, 2025
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
1 parent d35ea27 commit 720e529

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/backend/access/brin/brin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
567567
BrinOpaque *opaque;
568568
BlockNumber nblocks;
569569
BlockNumber heapBlk;
570-
int totalpages = 0;
570+
int64 totalpages = 0;
571571
FmgrInfo *consistentFn;
572572
MemoryContext oldcxt;
573573
MemoryContext perRangeCxt;

0 commit comments

Comments
 (0)