mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix: NetworkServer.OnTransportData header size is now checked before every message unpacking again like before batching.
This commit is contained in:
parent
e6b379fb8d
commit
bdb410e015
@ -429,13 +429,6 @@ internal static void OnTransportData(int connectionId, ArraySegment<byte> data,
|
||||
{
|
||||
if (connections.TryGetValue(connectionId, out NetworkConnectionToClient connection))
|
||||
{
|
||||
if (data.Count < MessagePacking.HeaderSize)
|
||||
{
|
||||
Debug.LogError($"NetworkServer: received Message was too short (messages should start with message id)");
|
||||
connection.Disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
// client might batch multiple messages into one packet.
|
||||
// feed it to the Unbatcher.
|
||||
// NOTE: we don't need to associate a channelId because we
|
||||
@ -455,8 +448,19 @@ internal static void OnTransportData(int connectionId, ArraySegment<byte> data,
|
||||
while (!isLoadingScene &&
|
||||
connection.unbatcher.GetNextMessage(out NetworkReader reader))
|
||||
{
|
||||
if (!UnpackAndInvoke(connection, reader, channelId))
|
||||
break;
|
||||
// enough to read at least header size?
|
||||
if (reader.Remaining >= MessagePacking.HeaderSize)
|
||||
{
|
||||
if (!UnpackAndInvoke(connection, reader, channelId))
|
||||
break;
|
||||
}
|
||||
// otherwise disconnect
|
||||
else
|
||||
{
|
||||
Debug.LogError($"NetworkServer: received Message was too short (messages should start with message id). Disconnecting {connectionId}");
|
||||
connection.Disconnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else Debug.LogError("HandleData Unknown connectionId:" + connectionId);
|
||||
|
Loading…
Reference in New Issue
Block a user