Restrict parse value to strtoll with restrictions on input.

This commit is contained in:
rakshasa
2026-09-30 12:01:13 +02:00
committed by Jari Sundell
parent 44d51171e1
commit c5d54fbb97
16 changed files with 440 additions and 60 deletions
+4
View File
@@ -1,5 +1,6 @@
#include "config.h"
#include <limits>
#include <memory>
#include <torrent/download/resource_manager.h>
@@ -232,6 +233,9 @@ apply_cg_max_set(const torrent::Object::list_type& args, bool is_up) {
int64_t second_arg = 0;
rpc::parse_whole_value(args.back().as_string().c_str(), &second_arg);
if (second_arg < -1 || second_arg > std::numeric_limits<uint32_t>::max())
throw torrent::input_error("Max unchoked must be between -1 and 4294967295.");
if (is_up)
cg_get_group(args.front())->up_queue()->set_max_unchoked(second_arg);
else