Re: Possible integer overflow in bringetbitmap()

2025-01-13 Thread Michael Paquier
On Fri, Jan 10, 2025 at 11:22:37AM -0800, James Hunter wrote: > Attached the proposed one-line fix. Thanks, applied and backpatched down to v13. While on it, I've checked all the other amgetbitmap callbacks and they all rely on an int64 for the result they return. So these parts are OK. -- Micha

Re: Possible integer overflow in bringetbitmap()

2025-01-11 Thread Michael Paquier
On Fri, Jan 10, 2025 at 11:22:37AM -0800, James Hunter wrote: > Attached the proposed one-line fix. Yes, that should be fine as-is based on the original topic. -- Michael signature.asc Description: PGP signature

Re: Possible integer overflow in bringetbitmap()

2025-01-10 Thread James Hunter
On Fri, Dec 20, 2024 at 3:22 PM Michael Paquier wrote: > > On Tue, Dec 10, 2024 at 12:33:08PM +0900, Michael Paquier wrote: > > Sure, you could do (a) and (b) together. It also seems to me that it > > is just simpler to make totalpages a int64 to map automatically with > > the result expected by

Re: Possible integer overflow in bringetbitmap()

2024-12-20 Thread Michael Paquier
On Tue, Dec 10, 2024 at 12:33:08PM +0900, Michael Paquier wrote: > Sure, you could do (a) and (b) together. It also seems to me that it > is just simpler to make totalpages a int64 to map automatically with > the result expected by the caller of bringetbitmap(), and we know that > based on MaxBloc

Re: Possible integer overflow in bringetbitmap()

2024-12-09 Thread Michael Paquier
On Thu, Dec 05, 2024 at 08:46:45AM -0800, James Hunter wrote: > On Wed, Dec 4, 2024 at 10:13 PM Michael Paquier 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

Re: Possible integer overflow in bringetbitmap()

2024-12-05 Thread James Hunter
On Wed, Dec 4, 2024 at 10:13 PM Michael Paquier 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 ran

Re: Possible integer overflow in bringetbitmap()

2024-12-04 Thread Michael Paquier
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 totalpage

Re: Possible integer overflow in bringetbitmap()

2024-12-04 Thread James Hunter
On Tue, Nov 26, 2024 at 2:57 AM Evgeniy Gorbanyov wrote: > > Function bringetbitmap() in src/backend/access/brin/brin.c:560 returns type > int64. But the returned variable 'totalpages' is of type int. Maybe it makes > sense to change the type of variable 'totalpages' to int64 to avoid possible

Possible integer overflow in bringetbitmap()

2024-11-26 Thread Evgeniy Gorbanyov
Hello. Function bringetbitmap() in src/backend/access/brin/brin.c:560 returns type int64. But the returned variable 'totalpages' is of type int. Maybe it makes sense to change the type of variable 'totalpages' to int64 to avoid possible overflow in expression 'totalpages * 10'? Patch is incl