summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-04-22 08:09:36 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-04-24 08:02:54 +0200
commit2e0f3799a809086054f6d5ac4120283b5bb6fa3b (patch)
tree25185798091df430b2ca9eb49cc23ef276d3db99 /src/network
parentbfb0ab3e2f5a5a09b4bf7f5584199425ffb1de50 (diff)
downloadopenttd-2e0f3799a809086054f6d5ac4120283b5bb6fa3b.tar.xz
Change: [Network] Prevent invalid client names being sent to the server when changing it using the console/settings
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_client.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 35c52d3bc..a80931c33 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -1308,6 +1308,11 @@ void NetworkUpdateClientName()
NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
if (ci == nullptr) return;
+ /* There is no validation on string settings, it is actually a post change callback.
+ * This method is called from that post change callback. So, when the client name is
+ * changed via the console there is no easy way to prevent an invalid name. Though,
+ * we can prevent it getting sent here. */
+ if (!NetworkValidateClientName()) return;
/* Don't change the name if it is the same as the old name */
if (strcmp(ci->client_name, _settings_client.network.client_name) != 0) {