WebSocketServer now sanitize destination peers.

When relaying messages in multiplayer mode.
Could cause a crash in case a malicious client sends a bogus packet and
for those cases where a peer has just disconnected and a message arrive
from another peer with the disconnected one as destination.

(cherry picked from commit 17be67b8c7)
This commit is contained in:
Fabio Alessandrelli 2019-08-19 17:21:24 +02:00 committed by Rémi Verschelde
parent 37794ea4c3
commit 53c2e2da50
1 changed files with 4 additions and 1 deletions

View File

@ -268,7 +268,10 @@ Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, cons
ERR_FAIL_COND_V(p_to == p_from, FAILED); ERR_FAIL_COND_V(p_to == p_from, FAILED);
return get_peer(p_to)->put_packet(p_buffer, p_buffer_size); // Sending to specific peer Ref<WebSocketPeer> peer_to = get_peer(p_to);
ERR_FAIL_COND_V(peer_to.is_null(), FAILED);
return peer_to->put_packet(p_buffer, p_buffer_size); // Sending to specific peer
} }
} }