Avoid overflow with simplehash
Ranier Vilela <ranier.vf@gmail.com>
From: Ranier Vilela <ranier.vf@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2023-07-06T14:28:18Z
Lists: pgsql-hackers
Attachments
- avoid-overflow-with-simplehash-start-iterate.patch (application/octet-stream) patch
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
Commits
-
Fix type of iterator variable in SH_START_ITERATE
- 9f236198c31d 12.16 landed
- 6143602ebaab 11.21 landed
- 1508b57d4b7a 14.9 landed
- 09391ddc9578 13.12 landed
- d12d1a9278df 15.4 landed
- 727d96511ef5 16.0 landed
- f0a94d81e4f7 17.0 landed