From 51dd174303c19bde0d78ce549ab493d33593921a Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 17 Jul 2015 18:48:20 -0400 Subject: [PATCH] fix performance issue when receiving UDP packets (the udp tracker would not reject DHT packets immediately) --- src/tracker_manager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tracker_manager.cpp b/src/tracker_manager.cpp index f5a80e2d4..44fcf9fab 100644 --- a/src/tracker_manager.cpp +++ b/src/tracker_manager.cpp @@ -328,7 +328,12 @@ namespace libtorrent return false; } - const char* ptr = buf + 4; + // the first word is the action, if it's not [0, 3] + // it's not a valid udp tracker response + const char* ptr = buf; + boost::uint32_t action = detail::read_uint32(ptr); + if (action > 3) return false; + boost::uint32_t transaction = detail::read_uint32(ptr); udp_conns_t::iterator i = m_udp_conns.find(transaction);