summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-02-20 16:28:53 +0100
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-02-20 16:28:53 +0100
commitdc583a6225faf5aa8e4a2891f559cc391d619fc8 (patch)
tree52b4bd9c33e71ec51893ba7b27faf018d7c3bf79
parentd39c0577c0642de94868f649916f7dbcb344cc11 (diff)
Add check to validate client IDs in ENet.
Server now checks that the ID received from the client is not already used by someone else and is a valid ID (>=2)
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index e53846e269..871c33bb35 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -231,6 +231,13 @@ void NetworkedMultiplayerENet::poll() {
break;
}
+ // A client joined with an invalid ID (neagtive values, 0, and 1 are reserved).
+ // Probably trying to exploit us.
+ if (server && ((int)event.data < 2 || peer_map.has((int)event.data))) {
+ enet_peer_reset(event.peer);
+ ERR_CONTINUE(true);
+ }
+
int *new_id = memnew(int);
*new_id = event.data;