merged fixes from RC_0_16

This commit is contained in:
Arvid Norberg
2013-11-08 07:23:36 +00:00
parent a00f396224
commit dafa812109
4 changed files with 20 additions and 4 deletions

View File

@@ -295,7 +295,7 @@ public:
virtual void send_buffer(char const* begin, int size, int flags = 0 virtual void send_buffer(char const* begin, int size, int flags = 0
, void (*fun)(char*, int, void*) = 0, void* userdata = 0); , void (*fun)(char*, int, void*) = 0, void* userdata = 0);
template <class Destructor> template <class Destructor>
void append_send_buffer(char* buffer, int size, Destructor const& destructor) void bt_append_send_buffer(char* buffer, int size, Destructor const& destructor)
{ {
#ifndef TORRENT_DISABLE_ENCRYPTION #ifndef TORRENT_DISABLE_ENCRYPTION
if (m_rc4_encrypted) if (m_rc4_encrypted)

View File

@@ -573,7 +573,7 @@ namespace libtorrent
template <class Destructor> template <class Destructor>
void append_send_buffer(char* buffer, int size, Destructor const& destructor void append_send_buffer(char* buffer, int size, Destructor const& destructor
, bool encrypted = false) , bool encrypted)
{ {
#if defined TORRENT_DISK_STATS #if defined TORRENT_DISK_STATS
log_buffer_usage(buffer, size, "queued send buffer"); log_buffer_usage(buffer, size, "queued send buffer");

View File

@@ -613,7 +613,7 @@ namespace libtorrent
// since we'll mutate it // since we'll mutate it
char* buf = (char*)malloc(size); char* buf = (char*)malloc(size);
memcpy(buf, buffer, size); memcpy(buf, buffer, size);
bt_peer_connection::append_send_buffer(buf, size, boost::bind(&::free, _1)); bt_append_send_buffer(buf, size, boost::bind(&::free, _1));
} }
else else
#endif #endif
@@ -2314,7 +2314,7 @@ namespace libtorrent
send_buffer(msg, 13); send_buffer(msg, 13);
} }
append_send_buffer(buffer.get(), r.length bt_append_send_buffer(buffer.get(), r.length
, boost::bind(&session_impl::free_disk_buffer , boost::bind(&session_impl::free_disk_buffer
, boost::ref(m_ses), _1)); , boost::ref(m_ses), _1));
buffer.release(); buffer.release();

View File

@@ -1263,6 +1263,22 @@ void upnp::on_upnp_map_response(error_code const& e
return; return;
} }
std::string ct = p.header("content-type");
if (!ct.empty()
&& ct.find_first_of("text/xml") == std::string::npos
&& ct.find_first_of("text/soap+xml") == std::string::npos
&& ct.find_first_of("application/xml") == std::string::npos
&& ct.find_first_of("application/soap+xml") == std::string::npos
)
{
char msg[300];
snprintf(msg, sizeof(msg), "error while adding port map: invalid content-type, \"%s\". Expected text/xml or application/soap+xml"
, ct.c_str());
log(msg, l);
next(d, mapping, l);
return;
}
// We don't want to ignore responses with return codes other than 200 // We don't want to ignore responses with return codes other than 200
// since those might contain valid UPnP error codes // since those might contain valid UPnP error codes