Store copies of command names added to xmlrpc-c.

This commit is contained in:
rakshasa
2025-11-17 10:07:20 +01:00
committed by Jari Sundell
parent b05ecb5c5a
commit b825906034
3 changed files with 57 additions and 25 deletions
+17
View File
@@ -4,10 +4,27 @@
#include "parse_commands.h"
#include <cstring>
#include <torrent/exceptions.h>
namespace rpc {
std::vector<std::unique_ptr<const char>> XmlRpc::m_command_names;
const char*
XmlRpc::store_command_name(const char* name) {
if (::strnlen(name, 8192) == 8192)
throw torrent::input_error("XMLRPC command name too long, limit is 8192 characters.");
for (const auto& itr : m_command_names) {
if (::strcmp(itr.get(), name) == 0)
return itr.get();
}
m_command_names.push_back(std::unique_ptr<const char>(::strdup(name)));
return m_command_names.back().get();
}
#ifndef HAVE_XMLRPC_C
#ifndef HAVE_XMLRPC_TINYXML2