From 2b1a7ceb4ee64292526ba4883f9cef9061992ba1 Mon Sep 17 00:00:00 2001 From: glx Date: Fri, 7 Feb 2020 23:19:57 +0100 Subject: Fix #7976: Don't kick the client doing the rcon --- src/network/network_server.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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++; -- cgit v1.2.3-70-g09d2