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 (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.
|
// client might batch multiple messages into one packet.
|
||||||
// feed it to the Unbatcher.
|
// feed it to the Unbatcher.
|
||||||
// NOTE: we don't need to associate a channelId because we
|
// 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 &&
|
while (!isLoadingScene &&
|
||||||
connection.unbatcher.GetNextMessage(out NetworkReader reader))
|
connection.unbatcher.GetNextMessage(out NetworkReader reader))
|
||||||
{
|
{
|
||||||
if (!UnpackAndInvoke(connection, reader, channelId))
|
// enough to read at least header size?
|
||||||
break;
|
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);
|
else Debug.LogError("HandleData Unknown connectionId:" + connectionId);
|
||||||
|
Loading…
Reference in New Issue
Block a user