summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2020-02-07 23:19:57 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2020-02-08 09:03:14 +0100
commit2b1a7ceb4ee64292526ba4883f9cef9061992ba1 (patch)
tree379ac5f70e54a8adf334ef9763ddc158754dfe6a /src/network
parent1a88fb5c910ed8badc9b7535487ff78fbdc7a38b (diff)
downloadopenttd-2b1a7ceb4ee64292526ba4883f9cef9061992ba1.tar.xz
Fix #7976: Don't kick the client doing the rcon
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_server.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index dd88042a1..36a15d3ae 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -2086,9 +2086,14 @@ uint NetworkServerKickOrBanIP(const char *ip, bool ban, const char *reason)
uint n = 0;
- /* There can be multiple clients with the same IP, kick them all */
+ /* There can be multiple clients with the same IP, kick them all but 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. */
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
if (cs->client_id == CLIENT_ID_SERVER) continue;
+ if (cs->client_id == _redirect_console_to_client) continue;
if (cs->client_address.IsInNetmask(ip)) {
NetworkServerKickClient(cs->client_id, reason);
n++;