From 9173382b595a58f1f1d473e5042b0af90b223879 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 27 Jul 2024 10:28:28 -0500 Subject: fix 32 bit integer overflow when computing byte limits --- src/slskd/Application.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index b9fc56b0..2e4e0daf 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -575,11 +575,11 @@ namespace slskd { var files = false; var megabytes = false; - var byteLimit = options?.Megabytes ?? defaults?.Megabytes; + var byteLimitInMegabytes = options?.Megabytes ?? defaults?.Megabytes; - if (byteLimit is not null && (stats.Bytes + size) > (byteLimit * 1000 * 1000)) + if (byteLimitInMegabytes is not null && (stats.Bytes + size) > (byteLimitInMegabytes * 1000L * 1000L)) { - Log.Debug("Projected bytes {Bytes} exceeds limit {Limit}", stats.Bytes + size, byteLimit * 1000 * 1000); + Log.Debug("Projected bytes {Bytes} exceeds limit {Limit}", stats.Bytes + size, byteLimitInMegabytes * 1000L * 1000L); megabytes = true; } -- cgit v1.2.3