diff options
author | rubidium42 <rubidium@openttd.org> | 2021-04-22 08:09:36 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-04-24 08:02:54 +0200 |
commit | 2e0f3799a809086054f6d5ac4120283b5bb6fa3b (patch) | |
tree | 25185798091df430b2ca9eb49cc23ef276d3db99 /src/console_cmds.cpp | |
parent | bfb0ab3e2f5a5a09b4bf7f5584199425ffb1de50 (diff) | |
download | openttd-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/console_cmds.cpp')
-rw-r--r-- | src/console_cmds.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index b3819115c..305444f8c 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -716,7 +716,14 @@ DEF_CONSOLE_CMD(ConClientNickChange) return true; } - if (!NetworkServerChangeClientName(client_id, argv[2])) { + char *client_name = argv[2]; + StrTrimInPlace(client_name); + if (!NetworkIsValidClientName(client_name)) { + IConsoleError("Cannot give a client an empty name"); + return true; + } + + if (!NetworkServerChangeClientName(client_id, client_name)) { IConsoleError("Cannot give a client a duplicate name"); } |