Re: Possible integer overflow in bringetbitmap()

From: James Hunter <james(dot)hunter(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Evgeniy Gorbanyov <gorbanyoves(at)basealt(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Possible integer overflow in bringetbitmap()
Date: 2024-12-05 16:46:45
Message-ID: CAJVSvF7vqexnSu9PRF_gDKFqgyR3qtG-L885s1wA+kn3t+euKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 4, 2024 at 10:13 PM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> 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..

Good point -- so the fix should be something like: (a) make totalpages
a BlockNumber or uint32; (b) cast either "totalpages" or "10" to
int64, before returning the result?

James

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Francesco Degrassi 2024-12-05 16:52:38 Re: RFC/PoC: GUC option to enable tuple queue autoflush for parallel workers
Previous Message Robert Haas 2024-12-05 16:43:49 Re: code contributions for 2024, WIP version