fdbased: uint32 to int may overflow on 32-bit

This commit is contained in:
ignoramous
2024-05-31 00:09:14 +05:30
committed by GitHub
parent 205026a8e6
commit 3c20222c76
+2 -2
View File
@@ -137,7 +137,7 @@ func (m *processorManager) connectionHash(cid *connectionID) uint32 {
// queuePacket queues a packet to be delivered to the appropriate processor.
func (m *processorManager) queuePacket(pkt *stack.PacketBuffer, hasEthHeader bool) {
var pIdx int
var pIdx uint32
cid, nonConnectionPkt := tcpipConnectionID(pkt)
if !hasEthHeader {
if nonConnectionPkt {
@@ -152,7 +152,7 @@ func (m *processorManager) queuePacket(pkt *stack.PacketBuffer, hasEthHeader boo
// first processor.
pIdx = 0
} else {
pIdx = int(m.connectionHash(&cid)) % len(m.processors)
pIdx = m.connectionHash(&cid) % uint32(len(m.processors))
}
p := &m.processors[pIdx]
p.mu.Lock()