diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 66b5a64cb..a57f4bd9d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3767,6 +3767,10 @@ static void Command_Ban(void) if (pn == -1 || pn == 0) return; + // player does not exist + if (!nodeingame[playernode[pn]]) + return; + WRITEUINT8(p, pn); if (COM_Argc() == 2) @@ -3884,6 +3888,10 @@ static void Command_Kick(void) if (pn == -1 || pn == 0) return; + // player does not exist + if (!nodeingame[playernode[pn]]) + return; + // Special case if we are trying to kick a player who is downloading the game state: // trigger a timeout instead of kicking them, because a kick would only // take effect after they have finished downloading @@ -3933,7 +3941,8 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum) pnum = READUINT8(*p); msg = READUINT8(*p); - if (pnum == serverplayer && IsPlayerAdmin(playernum)) + // FIXME: this does not work at all on dedi, servernode == 0 which is prevented from kick/ban command + if (playernode[pnum] == servernode && IsPlayerAdmin(playernum)) { CONS_Printf(M_GetText("Server is being shut down remotely. Goodbye!\n")); @@ -3943,6 +3952,16 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum) return; } + // without this the server will remove itself and thus self destruct on dedicated + if (!nodeingame[playernode[pnum]]) + { + CONS_Alert(CONS_WARNING, M_GetText("Attempting to kick player %d which is not in game received from %s\n"), pnum, player_names[playernum]); + return; + } + + // make sure we dont read garbage anywhere + memset(reason, 0, sizeof(buf)); + // Is playernum authorized to make this kick? if (playernum != serverplayer && !IsPlayerAdmin(playernum) /*&& !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2