mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-03 19:42:55 +00:00
Fix out-of-boundaries access in addSHLL function (#10840)
## Problem See https://github.com/neondatabase/neon/issues/10839 rho(x,b) functions returns values in range [1,b+1] and addSHLL tries to store it in array of size b+1. ## Summary of changes Subtract 1 fro value returned by rho --------- Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
This commit is contained in:
committed by
GitHub
parent
81f08d304a
commit
8c6d133d31
@@ -122,8 +122,8 @@ addSHLL(HyperLogLogState *cState, uint32 hash)
|
||||
index = hash >> HLL_C_BITS;
|
||||
|
||||
/* Compute the rank of the remaining 32 - "k" (registerWidth) bits */
|
||||
count = rho(hash << HLL_BIT_WIDTH, HLL_C_BITS);
|
||||
|
||||
count = rho(hash << HLL_BIT_WIDTH, HLL_C_BITS) - 1;
|
||||
Assert(count <= HLL_C_BITS);
|
||||
cState->regs[index][count] = now;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ getMaximum(const TimestampTz* reg, TimestampTz since)
|
||||
{
|
||||
if (reg[i] >= since)
|
||||
{
|
||||
max = i;
|
||||
max = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user