From debf455b2f0256c8338a7298c8f6ef02bafdca90 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 30 May 2025 02:54:34 +0200 Subject: [PATCH] Fix underflow in consistancy checking code https://git.srb2.org/Hanicef/SRB2Classic/-/commit/9f5686ef48956cd64ef92f737e59cbbaa27d8cf9 --- src/d_clisrv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4e5a1cd9a..0135c76cd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5388,7 +5388,7 @@ static void HandlePacketFromPlayer(SINT8 node) // Check player consistancy during the level if (gamestate == GS_LEVEL - && (realstart > gametic - TICQUEUE+1 && realstart <= gametic) + && (realstart <= gametic && realstart + TICQUEUE - 1 > gametic) && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && (!UseSaturnSynch(node) || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone()))) { @@ -5418,10 +5418,13 @@ static void HandlePacketFromPlayer(SINT8 node) } if (cv_blamecfail.value) + { CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), netconsole+1, player_names[netconsole], consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy)); + } + DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); @@ -5693,7 +5696,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; } - //Update client ping table from the server. + // Update client ping table from the server. if (client) { UINT8 i; @@ -6503,7 +6506,6 @@ static inline void PingUpdate(void) if (pingtimeout[i] > 0) pingtimeout[i]--; } - } //kick lagging players... unless everyone but the server's ping sucks.