pgsql: Fix potential integer overflow in bringetbitmap() - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: Fix potential integer overflow in bringetbitmap()
Date
Msg-id E1tXaBZ-001R8R-HP@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/bfda7d8dd6b392c5d55bfb032aa7848b20227e12

Modified Files
--------------
src/backend/access/brin/brin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Move information about pgstats kinds into its own header pgstat_
Next
From: Michael Paquier
Date:
Subject: pgsql: Bump PGSTAT_FILE_FORMAT_ID