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>main
parent
cf82e08096
commit
940577cd3c
|
@ -245,7 +245,7 @@ func (u *DeviceListUpdater) notifyWorkers(userID string) {
|
||||||
}
|
}
|
||||||
hash := fnv.New32a()
|
hash := fnv.New32a()
|
||||||
_, _ = hash.Write([]byte(remoteServer))
|
_, _ = hash.Write([]byte(remoteServer))
|
||||||
index := int(hash.Sum32()) % len(u.workerChans)
|
index := int(int64(hash.Sum32()) % int64(len(u.workerChans)))
|
||||||
|
|
||||||
ch := u.assignChannel(userID)
|
ch := u.assignChannel(userID)
|
||||||
u.workerChans[index] <- remoteServer
|
u.workerChans[index] <- remoteServer
|
||||||
|
|
Loading…
Reference in New Issue