Re: Avoid overflow with simplehash

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: Avoid overflow with simplehash
Дата
Msg-id 637F10BC-EB05-4460-A10B-D690DEB1FC5C@yesql.se
обсуждение исходный текст
Ответ на Avoid overflow with simplehash  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Avoid overflow with simplehash
Список pgsql-hackers
> On 6 Jul 2023, at 16:28, Ranier Vilela <ranier.vf@gmail.com> wrote:

> The function SH_START_ITERATE can trigger some overflow.
> 
> See:
> typedef struct SH_ITERATOR
> {
> uint32 cur; /* current element */
> uint32 end;
> bool done; /* iterator exhausted? */
> } SH_ITERATOR;
> 
> The cur field is uint32 size and currently can be stored a uint64,
> which obviously does not fit.

-    Assert(startelem < SH_MAX_SIZE);
+    Assert(startelem < PG_UINT32_MAX);

I mighe be missing something, but from skimming the current code, SH_MAX_SIZE
is currently defined as:

#define SH_MAX_SIZE (((uint64) PG_UINT32_MAX) + 1)

Can you show a reproducer example where you are able to overflow?

--
Daniel Gustafsson




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Amit Langote
Дата:
Сообщение: Re: generic plans and "initial" pruning
Следующее
От: Ranier Vilela
Дата:
Сообщение: Re: Avoid overflow with simplehash