From 80fba1f74847e9708c8cfa75d9828d656135c60a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 17 Jul 2016 14:23:54 -0700 Subject: [PATCH 1/4] fix crash in session::get_ip_filter when not having set one (#914) --- ChangeLog | 1 + src/session_impl.cpp | 1 + test/test_ip_filter.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4667a6b20..17b05d787 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 1.1.1 release + * fix crash in session::get_ip_filter when not having set one * fix filename escaping when repairing torrents with broken web seeds * fix bug where file_completed_alert would not be posted unless file_progress had been queries by the client diff --git a/src/session_impl.cpp b/src/session_impl.cpp index efd1ae0f4..33f0ddc6d 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1239,6 +1239,7 @@ namespace aux { ip_filter const& session_impl::get_ip_filter() { TORRENT_ASSERT(is_single_thread()); + if (!m_ip_filter) m_ip_filter = boost::make_shared(); return *m_ip_filter; } diff --git a/test/test_ip_filter.cpp b/test/test_ip_filter.cpp index 29aa50ea3..bdf6c252c 100644 --- a/test/test_ip_filter.cpp +++ b/test/test_ip_filter.cpp @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "libtorrent/socket_io.hpp" +#include "libtorrent/session.hpp" /* @@ -89,6 +90,18 @@ void test_rules_invariant(std::vector > const& r, ip_filter const& f } } +TORRENT_TEST(session_get_ip_filter) +{ + using namespace libtorrent; + session ses; + ip_filter const& ipf = ses.get_ip_filter(); +#if TORRENT_USE_IPV6 + TEST_EQUAL(boost::get<0>(ipf.export_filter()).size(), 1); +#else + TEST_EQUAL(ipf.export_filter().size(), 1); +#endif +} + TORRENT_TEST(ip_filter) { using namespace libtorrent; From 8f3bd1052e1fadb6231ab2783444c08650af003e Mon Sep 17 00:00:00 2001 From: Sivachandran Date: Mon, 18 Jul 2016 19:42:10 +0530 Subject: [PATCH 2/4] fix mutable dht_get_item failure when salt is non-empty (#909) --- include/libtorrent/kademlia/get_item.hpp | 1 - src/kademlia/get_item.cpp | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/kademlia/get_item.hpp b/include/libtorrent/kademlia/get_item.hpp index 00df641c9..2b6b592e1 100644 --- a/include/libtorrent/kademlia/get_item.hpp +++ b/include/libtorrent/kademlia/get_item.hpp @@ -72,7 +72,6 @@ protected: data_callback m_data_callback; item m_data; - std::string m_salt; bool m_immutable; }; diff --git a/src/kademlia/get_item.cpp b/src/kademlia/get_item.cpp index 317b9a151..61c9bd3c4 100644 --- a/src/kademlia/get_item.cpp +++ b/src/kademlia/get_item.cpp @@ -78,7 +78,8 @@ void get_item::got_data(bdecode_node const& v, // data can reach here, which means pk and sig must be valid. if (!pk || !sig) return; - std::pair salt(m_salt.c_str(), int(m_salt.size())); + std::string temp_copy(m_data.salt()); + std::pair salt(temp_copy.c_str(), int(temp_copy.size())); sha1_hash incoming_target = item_target_id(salt, pk); if (incoming_target != m_target) return; From e75bb120b4d0e0c711990749336ff55e87bdaacd Mon Sep 17 00:00:00 2001 From: terry zhao Date: Tue, 19 Jul 2016 00:19:45 +0800 Subject: [PATCH 3/4] fix range of lsd::cookie (#920) fix cookie range of lsd in lsd::on_announce --- src/lsd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lsd.cpp b/src/lsd.cpp index 312c90af7..b1aaf3c52 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -87,7 +87,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb , m_log_cb(log) #endif , m_broadcast_timer(ios) - , m_cookie(random()) + , m_cookie(random() & 0x7fffffff) , m_disabled(false) #if TORRENT_USE_IPV6 , m_disabled6(false) From 5bda955f8f8253cedb7a924ced754852b7bce070 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 20 Jul 2016 10:11:28 -0700 Subject: [PATCH 4/4] don't send bitfield to peers whose handshake we haven't fully received yet (#925) --- src/bt_peer_connection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 7d37f4704..cd55acb8d 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -270,6 +270,11 @@ namespace libtorrent disconnect_if_redundant(); if (m_disconnecting) return; + if (!m_sent_handshake) return; + // we haven't gotten far enough on the incoming handshake to be able to + // send the bitfield yet + if (m_state < read_packet_size) return; + // connections that are still in the handshake // will send their bitfield when the handshake // is done @@ -277,7 +282,6 @@ namespace libtorrent write_upload_only(); #endif - if (!m_sent_handshake) return; if (m_sent_bitfield) return; boost::shared_ptr t = associated_torrent().lock(); TORRENT_ASSERT(t);