]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ratelimit: fix integer overflow 17595/head
authorEtienne Doms <etienne.doms@gmail.com>
Thu, 12 Nov 2020 10:09:54 +0000 (11:09 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Nov 2020 13:35:06 +0000 (14:35 +0100)
If StartLimitIntervalSec is huge, or more specifically, set to "infinity", we need to take care about overflows.

src/basic/ratelimit.c

index 90b3feb8dd622aa4ba32e43a65aaeb02c2faacdf..bae2ec3ffc5f9f6fc6f75839f8466638733ba492 100644 (file)
@@ -19,7 +19,7 @@ bool ratelimit_below(RateLimit *r) {
         ts = now(CLOCK_MONOTONIC);
 
         if (r->begin <= 0 ||
-            r->begin + r->interval < ts) {
+            ts - r->begin > r->interval) {
                 r->begin = ts;
 
                 /* Reset counter */