diff --git a/Lidgren.Network/NetUnreliableSenderChannel.cs b/Lidgren.Network/NetUnreliableSenderChannel.cs index 46408315..b857ca64 100644 --- a/Lidgren.Network/NetUnreliableSenderChannel.cs +++ b/Lidgren.Network/NetUnreliableSenderChannel.cs @@ -59,6 +59,17 @@ internal override NetSendResult Enqueue(NetOutgoingMessage message) return NetSendResult.Dropped; } + if (message.LengthBits >= ushort.MaxValue + && m_connection.m_peerConfiguration.UnreliableSizeBehaviour == NetUnreliableSizeBehaviour.IgnoreMTU) + { + // drop message + this.m_connection.m_peer.LogError( + string.Format("Unreliable message max size exceeded: {0} bits (max {1})", + message.LengthBits, + ushort.MaxValue)); + return NetSendResult.Dropped; + } + m_queuedSends.Enqueue(message); m_connection.m_peer.m_needFlushSendQueue = true; // a race condition to this variable will simply result in a single superflous call to FlushSendQueue() return NetSendResult.Sent;