Re: Avoid possible overflow (src/port/bsearch_arg.c)

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Tomas Vondra <tomas(at)vondra(dot)me>, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Tomas Vondra <tv(at)fuzzy(dot)cz>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid possible overflow (src/port/bsearch_arg.c)
Date: 2024-10-28 16:52:15
Message-ID: 08507458-8222-483c-9234-150d1a607efe@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 28/10/2024 17:30, Tomas Vondra wrote:
>> Some of those other implementations have fixed this, others have not.
>> And they all seem to also have the "involes" typo in the comment that we
>> fixed in commit 7ef8b52cf07 :-). Ranier, you might want to submit this
>> fix to those other projects too.
>
> Thanks for fixing this, although I wonder if we can actually hit this,
> as we don't really allocate more than 1GB in most places. But it's
> possible, and the pre-bfa2cee code handled it fine.

Yeah, I didn't check closely I'm pretty sure none of the current
callsites can pass anything near INT_MAX elements.

While we're at it, there's this in dicts/spell.h:

> /*
> * Structure to store Hunspell options. Flag representation depends on flag
> * type. These flags are about support of compound words.
> */
> typedef struct CompoundAffixFlag
> {
> union
> {
> /* Flag name if flagMode is FM_CHAR or FM_LONG */
> const char *s;
> /* Flag name if flagMode is FM_NUM */
> uint32 i;
> } flag;
> /* we don't have a bsearch_arg version, so, copy FlagMode */
> FlagMode flagMode;
> uint32 value;
> } CompoundAffixFlag;

We have bsearch_arg() now, so we could switch to that and remove
'flagMode' from here.

--
Heikki Linnakangas
Neon (https://neon.tech)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alena Rybakina 2024-10-28 16:55:35 Re: POC, WIP: OR-clause support for indexes
Previous Message Aleksander Alekseev 2024-10-28 16:48:05 Re: general purpose array_sort