Re: [PATCH] Fix possible underflow in expression (maxoff - 1) - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: [PATCH] Fix possible underflow in expression (maxoff - 1)
Date
Msg-id CAH2-WzkqdPjE8F7gYwFZR_=7ksrdoz+-+0uTLRo+3dutJS-+UQ@mail.gmail.com
Whole thread Raw
In response to [PATCH] Fix possible underflow in expression (maxoff - 1)  (Ranier Vilela <ranier_gyn@hotmail.com>)
Responses RE: [PATCH] Fix possible underflow in expression (maxoff - 1)  (Ranier Vilela <ranier_gyn@hotmail.com>)
List pgsql-hackers
On Sun, Nov 24, 2019 at 9:58 AM Ranier Vilela <ranier_gyn@hotmail.com> wrote:
> Within the function _bt_afternewitemoff, at line 641, maxoff is used in an dangerous expression,
> without protection.:  (maxoff - 1)

I wrote this code. It's safe.

In general, it's not possible to split a page without it being
initialized, and having at least 2 items (not including the incoming
newitem). Besides, even if "maxoff" had an integer underflow the
behavior of the function would still be sane and defined. OffsetNumber
is an unsigned type.

Where are you getting this stuff from? Are you using a static analysis tool?

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: LISTEN/NOTIFY testing woes
Next
From: Julien Rouhaud
Date:
Subject: Re: Collation versioning