diff --git a/libtorrent/include/libtorrent/bandwidth_manager.hpp b/libtorrent/include/libtorrent/bandwidth_manager.hpp index 89efcb9e8..c3b4f5942 100644 --- a/libtorrent/include/libtorrent/bandwidth_manager.hpp +++ b/libtorrent/include/libtorrent/bandwidth_manager.hpp @@ -173,7 +173,7 @@ struct bandwidth_manager ++i->priority; ++i; } - m_queue.insert(i.base(), bw_queue_entry(peer, blk, priority)); + m_queue.insert(i.base(), bw_queue_entry(peer, blk, priority)); if (!m_queue.empty()) hand_out_bandwidth(l); } @@ -292,7 +292,7 @@ private: queue_t tmp; while (!m_queue.empty() && amount > 0) { - bw_queue_entry qe = m_queue.front(); + bw_queue_entry qe = m_queue.front(); TORRENT_ASSERT(qe.max_block_size > 0); m_queue.pop_front(); @@ -401,7 +401,7 @@ private: int m_current_quota; // these are the consumers that want bandwidth - typedef std::deque > queue_t; + typedef std::deque > queue_t; queue_t m_queue; // these are the consumers that have received bandwidth diff --git a/libtorrent/include/libtorrent/bandwidth_queue_entry.hpp b/libtorrent/include/libtorrent/bandwidth_queue_entry.hpp index f8b44846c..54f669062 100644 --- a/libtorrent/include/libtorrent/bandwidth_queue_entry.hpp +++ b/libtorrent/include/libtorrent/bandwidth_queue_entry.hpp @@ -37,16 +37,15 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { -template +template struct bw_queue_entry { - typedef typename PeerConnection::torrent_type torrent_type; bw_queue_entry(boost::intrusive_ptr const& pe , int blk, int prio) : peer(pe), torrent(peer->associated_torrent()) , max_block_size(blk), priority(prio) {} boost::intrusive_ptr peer; - boost::weak_ptr torrent; + boost::weak_ptr torrent; int max_block_size; int priority; // 0 is low prio }; diff --git a/libtorrent/include/libtorrent/bencode.hpp b/libtorrent/include/libtorrent/bencode.hpp index 1d3f1ea2b..9bea1d846 100755 --- a/libtorrent/include/libtorrent/bencode.hpp +++ b/libtorrent/include/libtorrent/bencode.hpp @@ -214,8 +214,14 @@ namespace libtorrent } template - void bdecode_recursive(InIt& in, InIt end, entry& ret, bool& err) + void bdecode_recursive(InIt& in, InIt end, entry& ret, bool& err, int depth) { + if (depth >= 100) + { + err = true; + return; + } + if (in == end) { err = true; @@ -247,7 +253,7 @@ namespace libtorrent { ret.list().push_back(entry()); entry& e = ret.list().back(); - bdecode_recursive(in, end, e, err); + bdecode_recursive(in, end, e, err, depth + 1); if (err) return; if (in == end) { @@ -268,10 +274,10 @@ namespace libtorrent while (*in != 'e') { entry key; - bdecode_recursive(in, end, key, err); + bdecode_recursive(in, end, key, err, depth + 1); if (err) return; entry& e = ret[key.string()]; - bdecode_recursive(in, end, e, err); + bdecode_recursive(in, end, e, err, depth + 1); if (err) return; if (in == end) { @@ -317,7 +323,7 @@ namespace libtorrent { entry e; bool err = false; - detail::bdecode_recursive(start, end, e, err); + detail::bdecode_recursive(start, end, e, err, 0); if (err) { #ifdef BOOST_NO_EXCEPTIONS @@ -332,3 +338,4 @@ namespace libtorrent } #endif // TORRENT_BENCODE_HPP_INCLUDED + diff --git a/libtorrent/include/libtorrent/peer_connection.hpp b/libtorrent/include/libtorrent/peer_connection.hpp index 13fab90ca..97d76a3d1 100755 --- a/libtorrent/include/libtorrent/peer_connection.hpp +++ b/libtorrent/include/libtorrent/peer_connection.hpp @@ -98,8 +98,6 @@ namespace libtorrent friend class invariant_access; public: - typedef torrent torrent_type; - enum channels { upload_channel, diff --git a/libtorrent/include/libtorrent/torrent.hpp b/libtorrent/include/libtorrent/torrent.hpp index 773188cce..92ea37a40 100755 --- a/libtorrent/include/libtorrent/torrent.hpp +++ b/libtorrent/include/libtorrent/torrent.hpp @@ -688,7 +688,7 @@ namespace libtorrent boost::scoped_ptr m_picker; // the queue of peer_connections that want more bandwidth - typedef std::deque > queue_t; + typedef std::deque > queue_t; queue_t m_bandwidth_queue[2]; std::vector m_trackers; diff --git a/libtorrent/src/instantiate_connection.cpp b/libtorrent/src/instantiate_connection.cpp index f9c997fb1..23a202da4 100644 --- a/libtorrent/src/instantiate_connection.cpp +++ b/libtorrent/src/instantiate_connection.cpp @@ -54,7 +54,7 @@ namespace libtorrent { s.instantiate(ios); s.get().set_proxy(ps.hostname, ps.port); - if (ps.type == proxy_settings::socks5_pw) + if (ps.type == proxy_settings::http_pw) s.get().set_username(ps.username, ps.password); } else if (ps.type == proxy_settings::socks5 diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index e04e0be71..dc2902096 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -2253,7 +2253,7 @@ namespace libtorrent ++i->priority; ++i; } - m_bandwidth_queue[channel].insert(i.base(), bw_queue_entry( + m_bandwidth_queue[channel].insert(i.base(), bw_queue_entry( p, block_size, priority)); } } @@ -2267,7 +2267,7 @@ namespace libtorrent queue_t tmp; while (!m_bandwidth_queue[channel].empty()) { - bw_queue_entry qe = m_bandwidth_queue[channel].front(); + bw_queue_entry qe = m_bandwidth_queue[channel].front(); if (m_bandwidth_limit[channel].max_assignable() == 0) break; m_bandwidth_queue[channel].pop_front(); diff --git a/libtorrent/src/torrent_handle.cpp b/libtorrent/src/torrent_handle.cpp index 092d77c78..635390537 100755 --- a/libtorrent/src/torrent_handle.cpp +++ b/libtorrent/src/torrent_handle.cpp @@ -503,7 +503,7 @@ namespace libtorrent session_impl::mutex_t::scoped_lock l(m_ses->m_mutex); mutex::scoped_lock l2(m_chk->m_mutex); - boost::shared_ptr t = m_ses->find_torrent(m_info_hash).lock(); + torrent* t = find_torrent(m_ses, m_chk, m_info_hash); if (!t || !t->valid_metadata()) #ifdef BOOST_NO_EXCEPTIONS return entry(); @@ -599,11 +599,13 @@ namespace libtorrent for (policy::iterator i = pol.begin_peer() , end(pol.end_peer()); i != end; ++i) { + asio::error_code ec; if (i->second.banned) { tcp::endpoint ip = i->second.ip; entry peer(entry::dictionary_t); - peer["ip"] = ip.address().to_string(); + peer["ip"] = ip.address().to_string(ec); + if (ec) continue; peer["port"] = ip.port(); banned_peer_list.push_back(peer); continue; @@ -619,7 +621,8 @@ namespace libtorrent tcp::endpoint ip = i->second.ip; entry peer(entry::dictionary_t); - peer["ip"] = ip.address().to_string(); + peer["ip"] = ip.address().to_string(ec); + if (ec) continue; peer["port"] = ip.port(); peer_list.push_back(peer); }