summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-05-03 15:05:15 +0000
committerrubidium <rubidium@openttd.org>2011-05-03 15:05:15 +0000
commit3c86fddf4ecd0cb194d10f73e36a0f6d6ff827d2 (patch)
treed7da226280a7a400ce10fbef5e52414dfe054d6f
parentff143c67085ad22abb5f6920873fd0ff9eddf603 (diff)
downloadopenttd-3c86fddf4ecd0cb194d10f73e36a0f6d6ff827d2.tar.xz
(svn r22414) -Fix [FS#4606]: kicking thyself via remote console crashes the server
-rw-r--r--src/console_cmds.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index caee5190f..895e0238d 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -495,7 +495,11 @@ static bool ConKickOrBan(const char *argv, bool ban)
if (strchr(argv, '.') == NULL && strchr(argv, ':') == NULL) { // banning with ID
ClientID client_id = (ClientID)atoi(argv);
- if (client_id == CLIENT_ID_SERVER) {
+ /* Don't kill the server, or the client doing the rcon. The latter can't be kicked because
+ * kicking frees closes and subsequently free the connection related instances, which we
+ * would be reading from and writing to after returning. So we would read or write data
+ * from freed memory up till the segfault triggers. */
+ if (client_id == CLIENT_ID_SERVER || client_id == _redirect_console_to_client) {
IConsolePrintF(CC_ERROR, "ERROR: Silly boy, you can not %s yourself!", ban ? "ban" : "kick");
return true;
}