From 2fb9c7141418b83cf856d6b67420683c9d51ccc7 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Thu, 19 Jul 2018 11:06:25 -0500 Subject: [PATCH] Don't allow end user to send random bytes --- .../Runtime/NetworkServer.cs | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Unity-Technologies-networking/Runtime/NetworkServer.cs b/Unity-Technologies-networking/Runtime/NetworkServer.cs index f717a6dc2..cb42c0ff6 100644 --- a/Unity-Technologies-networking/Runtime/NetworkServer.cs +++ b/Unity-Technologies-networking/Runtime/NetworkServer.cs @@ -325,7 +325,9 @@ static bool SendToObservers(GameObject contextObj, short msgType, MessageBase ms return false; } - static public void SendWriterToReady(GameObject contextObj, NetworkWriter writer, int channelId) + // End users should not send random bytes + // because the other side might interpret them as messages + static internal void SendWriterToReady(GameObject contextObj, NetworkWriter writer, int channelId) { if (writer.Position > UInt16.MaxValue) { @@ -335,7 +337,9 @@ static public void SendWriterToReady(GameObject contextObj, NetworkWriter writer SendBytesToReady(contextObj, writer.ToArray(), writer.Position, channelId); } - static public void SendBytesToReady(GameObject contextObj, byte[] buffer, int numBytes, int channelId) + // End users should not send random bytes + // because the other side might interpret them as messages + static internal void SendBytesToReady(GameObject contextObj, byte[] buffer, int numBytes, int channelId) { if (contextObj == null) { @@ -386,25 +390,6 @@ static public void SendBytesToReady(GameObject contextObj, byte[] buffer, int nu } } - public static void SendBytesToPlayer(GameObject player, byte[] buffer, int numBytes, int channelId) - { - for (int i = 0; i < connections.Count; i++) - { - var conn = connections[i]; - if (conn != null) - { - for (int j = 0; j < conn.playerControllers.Count; j++) - { - if (conn.playerControllers[j].IsValid && conn.playerControllers[j].gameObject == player) - { - conn.SendBytes(buffer, numBytes, channelId); - break; - } - } - } - } - } - static public bool SendByChannelToAll(short msgType, MessageBase msg, int channelId) { if (LogFilter.logDev) { Debug.Log("Server.SendByChannelToAll id:" + msgType); }