summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-08-19 17:21:24 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-08-19 17:26:07 +0200
commit17be67b8c726fe5c87a296e64a739033dd2890dd (patch)
tree8612666b6ec4cb01c924593c64e77c96f7d6fb1b
parentcce148b0242836b5c32a7fa6c39013a2fc1c9eff (diff)
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.
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 62f09bfbf9..362a1ebe0b 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -265,7 +265,10 @@ Error WebSocketMultiplayerPeer::_server_relay(int32_t p_from, int32_t p_to, cons
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
}
}