From dd82b9d1a8d0cf492384617aff4712a683e70007 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Mon, 29 Dec 2014 19:07:29 +0000 Subject: [PATCH] Fix case where interval overflows (thanks jackeri) [17:58] hey, you might be interested in checking out this https://github.com/etlegacy/etlegacy/commit/4da5a397b5994bfe5fddb9dad35bef5ddbea64c9#diff-acaedc9d8b492f9af8966ae68597392cR615 [17:58] its related to the ddos protection code you wrote [17:59] in continuation to: ab9b08e5845b0ff19814c996ad0cfb1dccab2790 [17:59] in a case if the client has in the past connected to the server days/weeks earlier and time wraps the client wont be able to connect [18:00] since in that case if the bucket of that clients ip still exists it wont get checked correctly --- code/server/sv_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/server/sv_main.c b/code/server/sv_main.c index ed50707e..4169fd2e 100644 --- a/code/server/sv_main.c +++ b/code/server/sv_main.c @@ -487,7 +487,7 @@ qboolean SVC_RateLimit( leakyBucket_t *bucket, int burst, int period ) { int expired = interval / period; int expiredRemainder = interval % period; - if ( expired > bucket->burst ) { + if ( expired > bucket->burst || interval < 0 ) { bucket->burst = 0; bucket->lastTime = now; } else {