Re: [PATCH] Fix possible underflow in expression (maxoff - 1)

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Ranier Vilela <ranier_gyn(at)hotmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Fix possible underflow in expression (maxoff - 1)
Date: 2019-11-24 19:07:37
Message-ID: CAH2-WzkqdPjE8F7gYwFZR_=7ksrdoz+-+0uTLRo+3dutJS-+UQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Nov 24, 2019 at 9:58 AM Ranier Vilela <ranier_gyn(at)hotmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Julien Rouhaud 2019-11-24 19:17:01 Re: Collation versioning
Previous Message Tom Lane 2019-11-24 19:04:38 Re: LISTEN/NOTIFY testing woes