mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 03:31:41 +00:00
Fix integer overflow in device_list_update.go (#1717)
Fix #1511 On 32-bits systems, int(hash.Sum32()) can be negative. This makes the computation of array indices using modulo invalid, crashing dendrite. Signed-off-by: Loïck Bonniot <git@lesterpig.com>
This commit is contained in:
parent
cf82e08096
commit
940577cd3c
@ -245,7 +245,7 @@ func (u *DeviceListUpdater) notifyWorkers(userID string) {
|
||||
}
|
||||
hash := fnv.New32a()
|
||||
_, _ = hash.Write([]byte(remoteServer))
|
||||
index := int(hash.Sum32()) % len(u.workerChans)
|
||||
index := int(int64(hash.Sum32()) % int64(len(u.workerChans)))
|
||||
|
||||
ch := u.assignChannel(userID)
|
||||
u.workerChans[index] <- remoteServer
|
||||
|
Loading…
Reference in New Issue
Block a user