Avoid overflow with simplehash - Mailing list pgsql-hackers

From Ranier Vilela
Subject Avoid overflow with simplehash
Date
Msg-id CAEudQAocXNJ6s1VLz+hMamLAQAiewRoW17OJ6-+9GACKfj6iPQ@mail.gmail.com
Whole thread Raw
Responses Re: Avoid overflow with simplehash
List pgsql-hackers
Hi,

SimpleHash.

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.

Also, the current index is int, which is possibly insufficient 
since items can be up to uint32.

Attached a fix.

best regards,
Ranier Vilela

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Schema variables - new implementation for Postgres 15
Next
From: Amit Langote
Date:
Subject: Re: generic plans and "initial" pruning