Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit 8f0bca8

Browse files
committed
transport: fixed an overflow in ShardPortIterator
1 parent 9993d1c commit 8f0bca8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

transport/routing.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ func RandomShardPort(si ShardInfo) uint16 {
3030
// ShardPortIterator returns iterator for consecutive ports that are
3131
// mapped to a specific shard on scylla node.
3232
func ShardPortIterator(si ShardInfo) func() uint16 {
33-
port := RandomShardPort(si)
33+
port := int(RandomShardPort(si))
3434

3535
return func() uint16 {
36-
port += si.NrShards
36+
port += int(si.NrShards)
3737
if port > maxPort {
38-
port = (minPort+si.NrShards-1)/si.NrShards*si.NrShards + si.Shard
38+
port = int((minPort+si.NrShards-1)/si.NrShards*si.NrShards + si.Shard)
3939
}
40-
return port
40+
return uint16(port)
4141
}
4242
}
4343

0 commit comments

Comments
 (0)