mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-22 09:06:18 +00:00
Check if target is null in xmlrpc_to_object().
This commit is contained in:
@@ -18,21 +18,18 @@ RpcManager::object_to_target(const torrent::Object& obj, int call_flags, rpc::ta
|
|||||||
if (call_flags & CommandMap::flag_no_target)
|
if (call_flags & CommandMap::flag_no_target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!obj.is_string()) {
|
if (!obj.is_string())
|
||||||
throw torrent::input_error("invalid parameters: target must be a string");
|
throw torrent::input_error("invalid parameters: target must be a string");
|
||||||
}
|
|
||||||
|
|
||||||
std::string target_string = obj.as_string();
|
std::string target_string = obj.as_string();
|
||||||
bool require_index = (call_flags & (CommandMap::flag_tracker_target | CommandMap::flag_file_target));
|
bool require_index = (call_flags & (CommandMap::flag_tracker_target | CommandMap::flag_file_target));
|
||||||
|
|
||||||
if (target_string.size() == 0 && !require_index) {
|
if (target_string.size() == 0 && !require_index)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Length of SHA1 hash is 40
|
// Length of SHA1 hash is 40
|
||||||
if (target_string.size() < 40) {
|
if (target_string.size() < 40)
|
||||||
throw torrent::input_error("invalid parameters: invalid target");
|
throw torrent::input_error("invalid parameters: invalid target");
|
||||||
}
|
|
||||||
|
|
||||||
char type = 'd';
|
char type = 'd';
|
||||||
std::string hash;
|
std::string hash;
|
||||||
|
|||||||
+1
-1
@@ -219,7 +219,7 @@ xmlrpc_to_object(xmlrpc_env* env, xmlrpc_value* value, int call_type, rpc::targe
|
|||||||
if (env->fault_occurred)
|
if (env->fault_occurred)
|
||||||
throw xmlrpc_error_c(env);
|
throw xmlrpc_error_c(env);
|
||||||
|
|
||||||
if (target->first == XmlRpc::call_download &&
|
if (target != nullptr && target->first == XmlRpc::call_download &&
|
||||||
(call_type == XmlRpc::call_file || call_type == XmlRpc::call_tracker)) {
|
(call_type == XmlRpc::call_file || call_type == XmlRpc::call_tracker)) {
|
||||||
// If we have a download target and the call type requires
|
// If we have a download target and the call type requires
|
||||||
// another contained type, then we try to use the next
|
// another contained type, then we try to use the next
|
||||||
|
|||||||
Reference in New Issue
Block a user