com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Integer overflow for maxCapacity calculation from large m_DisconnectTimeoutMS

Open zachstronaut opened this issue 2 months ago • 1 comments

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."

zachstronaut avatar Oct 15 '25 15:10 zachstronaut

Sounds like we should cap the maximum timeout value indeed.

Nice find! 👍

NoelStephensUnity avatar Oct 15 '25 22:10 NoelStephensUnity