Re: Possible integer overflow in bringetbitmap()

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: James Hunter <james.hunter.pg@gmail.com>
Cc: Evgeniy Gorbanyov <gorbanyoves@basealt.ru>, pgsql-hackers@lists.postgresql.org
Date: 2024-12-05T06:13:14Z
Lists: pgsql-hackers
On Wed, Dec 04, 2024 at 02:05:10PM -0800, James Hunter wrote:
> So, I think your patch should be, instead, to cast either "totalpages"
> or "10" to "int64", in the return statement.

totalpages is signed, and BlockNumber is unsigned.  Hence in theory
you could always fall into a trap once totalpages gets higher than
(2^31 - 1), no?  This is not going to be a problem in practice even if
the number of pages per range assigned to brin can be 1, still..
--
Michael

Commits

  1. Fix potential integer overflow in bringetbitmap()