void-packages/srcpkgs/rtorrent/patches/fix-xml-rpc-overflow.patch

77 lines
4.0 KiB
Diff
Raw Normal View History

2019-01-01 06:21:18 +01:00
From 1f418366d4e56d96420459ea868a3c23f7c297e8 Mon Sep 17 00:00:00 2001
From: chros <chros@chrosGX620>
Date: Mon, 1 Oct 2018 23:27:58 +0100
Subject: [PATCH] Fix 'list' type method (See #25)
---
src/command_dynamic.cc | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git src/command_dynamic.cc src/command_dynamic.cc
index 91eb3c46..a8d0ff02 100644
--- src/command_dynamic.cc
+++ src/command_dynamic.cc
@@ -139,6 +139,8 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
case rpc::object_storage::flag_function_type:
system_method_generate_command2(&value, itrArgs, args.end());
break;
+ case rpc::object_storage::flag_list_type:
+ break;
case rpc::object_storage::flag_multi_type:
break;
default:
@@ -152,7 +154,17 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
if (!(flags & rpc::object_storage::flag_private))
cmd_flags |= rpc::CommandMap::flag_public_xmlrpc;
- control->object_storage()->insert_str(rawKey, value, flags);
+ if ((flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_list_type) {
+ torrent::Object valueList = torrent::Object::create_list();
+ torrent::Object::list_type& valueListType = valueList.as_list();
+
+ if ((itrArgs)->is_list())
+ valueListType = (itrArgs)->as_list();
+
+ control->object_storage()->insert_str(rawKey, valueList, flags);
+ } else {
+ control->object_storage()->insert_str(rawKey, value, flags);
+ }
if ((flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_function_type ||
(flags & rpc::object_storage::mask_type) == rpc::object_storage::flag_multi_type) {
@@ -208,6 +220,13 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
&rpc::command_base_call_string<rpc::target_type>,
cmd_flags, NULL, NULL);
break;
+ case rpc::object_storage::flag_list_type:
+ rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_list<rpc::target_type> >::type>
+ (create_new_key<5>(rawKey, ".set"),
+ std::bind(&rpc::object_storage::set_str_list, control->object_storage(), rawKey, std::placeholders::_2),
+ &rpc::command_base_call_list<rpc::target_type>,
+ cmd_flags, NULL, NULL);
+ break;
case rpc::object_storage::flag_function_type:
case rpc::object_storage::flag_multi_type:
default: break;
@@ -310,10 +329,6 @@ system_method_insert(const torrent::Object::list_type& args) {
new_flags = rpc::object_storage::flag_string_type;
else if (options.find("list") != std::string::npos)
new_flags = rpc::object_storage::flag_list_type;
- else if (options.find("simple") != std::string::npos)
- new_flags = rpc::object_storage::flag_function_type;
- else
- throw torrent::input_error("No support for 'list' variable type.");
if (options.find("static") != std::string::npos)
new_flags |= rpc::object_storage::flag_static;
@@ -447,6 +462,9 @@ initialize_command_dynamic() {
CMD2_ANY_LIST ("method.insert", std::bind(&system_method_insert, std::placeholders::_2));
CMD2_ANY_LIST ("method.insert.value", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_value_type));
+ CMD2_ANY_LIST ("method.insert.bool", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_bool_type));
+ CMD2_ANY_LIST ("method.insert.string", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_string_type));
+ CMD2_ANY_LIST ("method.insert.list", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_list_type));
CMD2_METHOD_INSERT("method.insert.simple", rpc::object_storage::flag_function_type);
CMD2_METHOD_INSERT("method.insert.c_simple", rpc::object_storage::flag_constant | rpc::object_storage::flag_function_type);