pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix potential integer overflow in bringetbitmap()
Date: Tue, 14 Jan 2025 06:13:57 +0000
Message-ID: <E1tXaBZ-001R8N-Fw@gemulon.postgresql.org> (raw)

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/720e529840d5a1087a34db445f624c5ece46eb38

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



view thread (6+ messages)  latest in thread

Message-ID: <E1tXaBZ-001R8N-Fw@gemulon.postgresql.org>
Permalink:  ../E1tXaBZ-001R8N-Fw@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1tXaBZ-001R8N-Fw@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix potential integer overflow in bringetbitmap()
  In-Reply-To: <E1tXaBZ-001R8N-Fw@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox