expand buffer sizes for upnp error messages

This commit is contained in:
Arvid Norberg 2014-03-23 22:49:09 +00:00
parent 946aecdb59
commit fa2ea57e43
1 changed files with 39 additions and 39 deletions

View File

@ -149,7 +149,7 @@ void upnp::discover_device_impl(mutex::scoped_lock& l)
if (ec)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "broadcast failed: %s. Aborting."
, convert_from_native(ec.message()).c_str());
log(msg, l);
@ -173,7 +173,7 @@ int upnp::add_mapping(upnp::protocol_type p, int external_port, int local_port)
{
mutex::scoped_lock l(m_mutex);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "adding port map: [ protocol: %s ext_port: %u "
"local_port: %u ] %s", (p == tcp?"tcp":"udp"), external_port
, local_port, m_disabled ? "DISABLED": "");
@ -225,7 +225,7 @@ void upnp::delete_mapping(int mapping)
global_mapping_t& m = m_mappings[mapping];
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "deleting port map: [ protocol: %s ext_port: %u "
"local_port: %u ]", (m.protocol == tcp?"tcp":"udp"), m.external_port
, m.local_port);
@ -295,7 +295,7 @@ void upnp::resend_request(error_code const& ec)
TORRENT_ASSERT(d.magic == 1337);
TORRENT_TRY
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "connecting to: %s", d.url.c_str());
log(msg, l);
if (d.upnp_connection) d.upnp_connection->close();
@ -307,7 +307,7 @@ void upnp::resend_request(error_code const& ec)
TORRENT_CATCH (std::exception& exc)
{
TORRENT_DECLARE_DUMMY(std::exception, exc);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "connection failed to: %s %s", d.url.c_str(), exc.what());
log(msg, l);
d.disabled = true;
@ -356,7 +356,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
{
if (ec)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "when receiving response from: %s: %s"
, print_endpoint(from).c_str(), convert_from_native(ec.message()).c_str());
log(msg, l);
@ -391,7 +391,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
// list of configured routers
if (ec)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "failed to enumerate routes when "
"receiving response from: %s: %s"
, print_endpoint(from).c_str(), convert_from_native(ec.message()).c_str());
@ -421,7 +421,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
, buffer + bytes_transferred), error);
if (error)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "received malformed HTTP from: %s"
, print_endpoint(from).c_str());
log(msg, l);
@ -432,14 +432,14 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
{
if (p.method().empty())
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "HTTP status %u from %s"
, p.status_code(), print_endpoint(from).c_str());
log(msg, l);
}
else
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "HTTP method %s from %s"
, p.method().c_str(), print_endpoint(from).c_str());
log(msg, l);
@ -449,7 +449,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
if (!p.header_finished())
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "incomplete HTTP packet from %s"
, print_endpoint(from).c_str());
log(msg, l);
@ -459,7 +459,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
std::string url = p.header("location");
if (url.empty())
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "missing location header from %s"
, print_endpoint(from).c_str());
log(msg, l);
@ -483,7 +483,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
if (ec)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "invalid URL %s from %s: %s"
, d.url.c_str(), print_endpoint(from).c_str(), convert_from_native(ec.message()).c_str());
log(msg, l);
@ -495,7 +495,7 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
if (protocol != "http")
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "unsupported protocol %s from %s"
, protocol.c_str(), print_endpoint(from).c_str());
log(msg, l);
@ -504,21 +504,21 @@ void upnp::on_reply(udp::endpoint const& from, char* buffer
if (d.port == 0)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "URL with port 0 from %s"
, print_endpoint(from).c_str());
log(msg, l);
return;
}
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "found rootdevice: %s (%d)"
, d.url.c_str(), int(m_devices.size()));
log(msg, l);
if (m_devices.size() >= 50)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "too many rootdevices: (%d). Ignoring %s"
, int(m_devices.size()), d.url.c_str());
log(msg, l);
@ -585,7 +585,7 @@ void upnp::try_map_upnp(mutex::scoped_lock& l, bool timer)
== m_devices.end();
if (override_ignore_non_routers)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "overriding ignore non-routers");
log(msg, l);
}
@ -610,7 +610,7 @@ void upnp::try_map_upnp(mutex::scoped_lock& l, bool timer)
TORRENT_ASSERT(d.magic == 1337);
TORRENT_TRY
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "connecting to: %s"
, d.url.c_str());
log(msg, l);
@ -624,7 +624,7 @@ void upnp::try_map_upnp(mutex::scoped_lock& l, bool timer)
TORRENT_CATCH (std::exception& exc)
{
TORRENT_DECLARE_DUMMY(std::exception, exc);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "connection failed to: %s %s"
, d.url.c_str(), exc.what());
log(msg, l);
@ -667,7 +667,7 @@ void upnp::create_port_mapping(http_connection& c, rootdevice& d, int i)
if (!d.upnp_connection)
{
TORRENT_ASSERT(d.disabled);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "mapping %u aborted", i);
log(msg, l);
return;
@ -734,7 +734,7 @@ void upnp::update_map(rootdevice& d, int i, mutex::scoped_lock& l)
if (m.action == mapping_t::action_none
|| m.protocol == none)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "mapping %u does not need updating, skipping", i);
log(msg, l);
m.action = mapping_t::action_none;
@ -745,7 +745,7 @@ void upnp::update_map(rootdevice& d, int i, mutex::scoped_lock& l)
TORRENT_ASSERT(!d.upnp_connection);
TORRENT_ASSERT(d.service_namespace);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "connecting to %s", d.hostname.c_str());
log(msg, l);
if (m.action == mapping_t::action_add)
@ -790,7 +790,7 @@ void upnp::delete_port_mapping(rootdevice& d, int i)
if (!d.upnp_connection)
{
TORRENT_ASSERT(d.disabled);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "unmapping %u aborted", i);
log(msg, l);
return;
@ -916,7 +916,7 @@ void upnp::on_upnp_xml(error_code const& e
if (e && e != asio::error::eof)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while fetching control url from: %s: %s"
, d.url.c_str(), convert_from_native(e.message()).c_str());
log(msg, l);
@ -926,7 +926,7 @@ void upnp::on_upnp_xml(error_code const& e
if (!p.header_finished())
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while fetching control url from: %s: incomplete HTTP message"
, d.url.c_str());
log(msg, l);
@ -936,7 +936,7 @@ void upnp::on_upnp_xml(error_code const& e
if (p.status_code() != 200)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while fetching control url from: %s: %s"
, d.url.c_str(), convert_from_native(p.message()).c_str());
log(msg, l);
@ -967,7 +967,7 @@ void upnp::on_upnp_xml(error_code const& e
}
else
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "could not find a port mapping interface in response from: %s"
, d.url.c_str());
log(msg, l);
@ -999,7 +999,7 @@ void upnp::on_upnp_xml(error_code const& e
+ to_string(d.port).elems + s.control_url;
}
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "found control URL: %s namespace %s "
"urlbase: %s in response from %s"
, d.control_url.c_str(), d.service_namespace
@ -1012,7 +1012,7 @@ void upnp::on_upnp_xml(error_code const& e
if (ec)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "failed to parse URL '%s': %s"
, d.control_url.c_str(), convert_from_native(ec.message()).c_str());
log(msg, l);
@ -1037,7 +1037,7 @@ void upnp::get_ip_address(rootdevice& d)
if (!d.upnp_connection)
{
TORRENT_ASSERT(d.disabled);
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "getting external IP address");
log(msg, l);
return;
@ -1177,7 +1177,7 @@ struct upnp_error_category : boost::system::error_category
{
return e->msg;
}
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "unknown UPnP error (%d)", ev);
return msg;
}
@ -1224,7 +1224,7 @@ void upnp::on_upnp_get_ip_address_response(error_code const& e
if (e && e != asio::error::eof)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while getting external IP address: %s"
, convert_from_native(e.message()).c_str());
log(msg, l);
@ -1241,7 +1241,7 @@ void upnp::on_upnp_get_ip_address_response(error_code const& e
if (p.status_code() != 200)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while getting external IP address: %s"
, convert_from_native(p.message()).c_str());
log(msg, l);
@ -1268,7 +1268,7 @@ void upnp::on_upnp_get_ip_address_response(error_code const& e
, boost::bind(&find_ip_address, _1, _2, boost::ref(s)));
if (s.error_code != -1)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while getting external IP address, code: %u"
, s.error_code);
log(msg, l);
@ -1302,7 +1302,7 @@ void upnp::on_upnp_map_response(error_code const& e
if (e && e != asio::error::eof)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while adding port map: %s"
, convert_from_native(e.message()).c_str());
log(msg, l);
@ -1361,7 +1361,7 @@ void upnp::on_upnp_map_response(error_code const& e
if (s.error_code != -1)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while adding port map, code: %u"
, s.error_code);
log(msg, l);
@ -1480,7 +1480,7 @@ void upnp::on_upnp_unmap_response(error_code const& e
if (e && e != asio::error::eof)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while deleting portmap: %s"
, convert_from_native(e.message()).c_str());
log(msg, l);
@ -1491,7 +1491,7 @@ void upnp::on_upnp_unmap_response(error_code const& e
}
else if (p.status_code() != 200)
{
char msg[200];
char msg[500];
snprintf(msg, sizeof(msg), "error while deleting portmap: %s"
, convert_from_native(p.message()).c_str());
log(msg, l);