com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
Integer overflow for maxCapacity calculation from large m_DisconnectTimeoutMS
Description
The calculation of maxCapacity in UnityTransport.cs is:
var maxCapacity = m_MaxSendQueueSize > 0 ? m_MaxSendQueueSize : m_DisconnectTimeoutMS * k_MaxReliableThroughput;
If a developer sets a very, very high (large) m_DisconnectTimeoutMS in the Editor for Unity Transport this maxCapacity calculation will overflow.
The overflow to a negative number will result in a BatchedSendQueue capacity of m_MaxPayloadSize, which is potentially much smaller than timeout * k_MaxReliableThroughput.
This will then result in unexpected disconnections:
$"Couldn't add payload of size {payload.Count} to reliable send queue. " +
$"Closing connection {ngoClientId} as reliability guarantees can't be maintained."
Sounds like we should cap the maximum timeout value indeed.
Nice find! 👍