Reject a throttle rate that overflows

rate * 1024 wraps to zero at 2^54, which means no limit.
This commit is contained in:
noctuum
2026-09-19 00:10:04 +05:00
committed by Jari Sundell
parent 84a0d86f2c
commit 0d3404576a
+4
View File
@@ -1,6 +1,7 @@
#include "config.h"
#include <cstdio>
#include <limits>
#include <torrent/throttle.h>
#include <torrent/rate.h>
#include <torrent/download/resource_manager.h>
@@ -90,6 +91,9 @@ apply_throttle(const torrent::Object::list_type& args, bool up) {
if (rate < 0)
throw torrent::input_error("Throttle rate must be non-negative.");
if (rate > (std::numeric_limits<int64_t>::max() >> 10))
throw torrent::input_error("Throttle rate is too large.");
auto itr = control->core()->throttles().find(name);
if (itr == control->core()->throttles().end())