From d7b2cfe4f20b08672129679ee3d3a89528920c46 Mon Sep 17 00:00:00 2001 From: xirvik Date: Fri, 21 Aug 2026 16:02:07 +0000 Subject: [PATCH] Clamp the elapsed time conversion instead of overflowing. convert.elapsed_time subtracted an unchecked value from the cached seconds. --- src/command_ui.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_ui.cc b/src/command_ui.cc index 6e0bd8c8..1d53b1e6 100644 --- a/src/command_ui.cc +++ b/src/command_ui.cc @@ -408,8 +408,9 @@ apply_to_time(const torrent::Object& rawArgs, int flags) { torrent::Object apply_to_elapsed_time(const torrent::Object& rawArgs) { auto cached_seconds = torrent::this_thread::cached_seconds().count(); + auto value = rawArgs.as_value(); - uint64_t arg = cached_seconds - rawArgs.as_value(); + uint64_t arg = value >= 0 && value <= cached_seconds ? cached_seconds - value : 0; char buffer[48]; snprintf(buffer, 48, "%2d:%02d:%02d", (int)(arg / 3600), (int)((arg / 60) % 60), (int)(arg % 60));