From ae5a725f80a7bf2e774ba098af0011e269e8692b Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Wed, 21 Jun 2023 10:32:35 +0200 Subject: [PATCH] avoid integer overflow for cache-limit Without this, "mb * 1024 * 1024" overflows for mb >= 2048. The result is then cast into size_t, which is unsigned and usually a 64-bit integer. The end result is, that the cache is now basically unlimited. Fix this by making sure that the multiplication operated on 64-bit values. --- daemon/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/main.cpp b/daemon/main.cpp index 2b9082f3..b5c685d5 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -2349,7 +2349,7 @@ int main(int argc, char **argv) int mb = atoi(optarg); if (!errno) { - cache_size_limit = mb * 1024 * 1024; + cache_size_limit = mb * 1024L * 1024; } } else { usage("Error: --cache-limit requires argument");