This commit is contained in:
Marcos Pinto 2008-01-07 01:36:09 +00:00
parent d76ed8cfba
commit 294e1f6b76
6 changed files with 38 additions and 8 deletions

View File

@ -325,7 +325,7 @@ private:
l.unlock();
t->expire_bandwidth(m_channel, qe.max_block_size);
l.lock();
TORRENT_ASSERT(amount == limit - m_current_quota);
amount = limit - m_current_quota;
continue;
}
@ -400,7 +400,7 @@ private:
l.lock();
add_history_entry(history_entry<PeerConnection, Torrent>(
qe.peer, t, hand_out_amount, now + bw_window_size));
TORRENT_ASSERT(amount == limit - m_current_quota);
amount = limit - m_current_quota;
}
if (!q.empty()) m_queue.insert(m_queue.begin(), q.begin(), q.end());
if (!tmp.empty()) m_queue.insert(m_queue.begin(), tmp.begin(), tmp.end());

View File

@ -201,7 +201,7 @@ namespace libtorrent
for (std::list<socket_entry>::iterator i = m_sockets.begin()
, end(m_sockets.end()); i != end; ++i)
{
if (!socket) continue;
if (!i->socket) continue;
i->socket->close();
}
}

View File

@ -2668,6 +2668,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "**ERROR**: " << error.message() << "[in peer_connection::on_receive_data]\n";
#endif
set_failed();
on_receive(error, bytes_transferred);
throw std::runtime_error(error.message());
}
@ -2828,6 +2829,7 @@ namespace libtorrent
(*m_ses.m_logger) << "CONNECTION FAILED: " << m_remote.address().to_string()
<< ": " << e.message() << "\n";
#endif
set_failed();
m_ses.connection_failed(self(), m_remote, e.message().c_str());
return;
}
@ -2888,6 +2890,7 @@ namespace libtorrent
#ifdef TORRENT_VERBOSE_LOGGING
(*m_logger) << "**ERROR**: " << error.message() << " [in peer_connection::on_send_data]\n";
#endif
set_failed();
throw std::runtime_error(error.message());
}
if (m_disconnecting) return;

View File

@ -1589,6 +1589,18 @@ namespace libtorrent
p->set_peer_info(0);
TORRENT_ASSERT(i != m_connections.end());
m_connections.erase(i);
// remove from bandwidth request-queue
for (int c = 0; c < 2; ++c)
{
for (queue_t::iterator i = m_bandwidth_queue[c].begin()
, end(m_bandwidth_queue[c].end()); i != end; ++i)
{
if (i->peer != p) continue;
m_bandwidth_queue[c].erase(i);
break;
}
}
}
catch (std::exception& e)
{
@ -2605,6 +2617,9 @@ namespace libtorrent
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
TORRENT_ASSERT(m_bandwidth_queue[0].size() <= m_connections.size());
TORRENT_ASSERT(m_bandwidth_queue[1].size() <= m_connections.size());
int num_uploads = 0;
std::map<piece_block, int> num_requests;
for (const_peer_iterator i = begin(); i != end(); ++i)

View File

@ -350,10 +350,23 @@ namespace libtorrent
{ m_name = info["name"].string(); }
fs::path tmp = m_name;
if (tmp.is_complete()) throw std::runtime_error("torrent contains "
"a file with an absolute path: '" + m_name + "'");
if (tmp.has_branch_path()) throw std::runtime_error(
"torrent contains name with directories: '" + m_name + "'");
if (tmp.is_complete())
{
m_name = tmp.leaf();
}
else if (tmp.has_branch_path())
{
fs::path p;
for (fs::path::iterator i = tmp.begin()
, end(tmp.end()); i != end; ++i)
{
if (*i == "." || *i == "..") continue;
p /= *i;
}
m_name = p.string();
}
if (m_name == ".." || m_name == ".")
throw std::runtime_error("invalid 'name' of torrent (possible exploit attempt)");
// extract file list
entry const* i = info.find_key("files");

View File

@ -106,7 +106,6 @@ namespace libtorrent
, udp::resolver::iterator i) try
{
if (error == asio::error::operation_aborted) return;
if (!m_socket.is_open()) return; // the operation was aborted
if (error || i == udp::resolver::iterator())
{
fail(-1, error.message().c_str());