]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: init: address a coverity warning about possible multiply overflow
authorWilly Tarreau <w@1wt.eu>
Tue, 24 May 2022 05:43:57 +0000 (07:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 24 May 2022 05:46:00 +0000 (07:46 +0200)
In issue #1585 Coverity suspects a risk of multiply overflow when
calculating the SSL cache size, though in practice the cache is
limited to 2^32 anyway thus it cannot really happen. Nevertheless,
casting the operation should be sufficient to avoid marking it as a
false positive.

src/haproxy.c

index 1d6612619e2e3607b28752bf842893022eba8e17..130bc9b35487521b59e8b41dc874201b0d070478 100644 (file)
@@ -2302,7 +2302,7 @@ static void init(int argc, char **argv)
                int64_t mem = global.rlimit_memmax * 1048576ULL;
                int retried = 0;
 
-               mem -= global.tune.sslcachesize * 200; // about 200 bytes per SSL cache entry
+               mem -= global.tune.sslcachesize * 200ULL; // about 200 bytes per SSL cache entry
                mem -= global.maxzlibmem;
                mem = mem * MEM_USABLE_RATIO;