From a7e9b67e37c3f022c7c2a4a0ebd86dc1f5537471 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 21 Sep 2014 11:10:59 -0300 Subject: [PATCH] don't accept DHT posts with time in far-future. (timeline still need to be fixed though) --- libtorrent/src/kademlia/dht_get.cpp | 8 ++++++++ libtorrent/src/kademlia/node.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/libtorrent/src/kademlia/dht_get.cpp b/libtorrent/src/kademlia/dht_get.cpp index 77892de5..26f4bc09 100644 --- a/libtorrent/src/kademlia/dht_get.cpp +++ b/libtorrent/src/kademlia/dht_get.cpp @@ -121,6 +121,14 @@ void dht_get_observer::reply(msg const& m) #endif continue; } + + int64 p_time = p->dict_find_int_value("time"); + if(!p_time || p_time > GetAdjustedTime() + 2*60*60 ) { +#ifdef TORRENT_DHT_VERBOSE_LOGGING + TORRENT_LOG(traversal) << "dht_get_observer::reply invalid time"; +#endif + continue; + } values_list.push_back(entry()); values_list.back() = *e; diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index db08fd66..f5736335 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -1430,6 +1430,11 @@ void node_impl::incoming_request(msg const& m, entry& e) return; } + if (msg_keys[mk_time]->int_value() > GetAdjustedTime() + 2*60*60) { + incoming_error(e, "time > GetAdjustedTime"); + return; + } + m_table.node_seen(id, m.addr, 0xffff); //f->last_seen = time_now();