diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-30 17:20:12 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-11-30 17:20:12 -0800 |
commit | ceaef19fb70523852441c8dd3ba647fa6ad217b9 (patch) | |
tree | d9573592687463e105e6e1d7af71690fd0c8736c /node | |
parent | 944fdfb65e260ed58a91097e42747ccb80c06f6f (diff) | |
download | infinitytier-ceaef19fb70523852441c8dd3ba647fa6ad217b9.tar.gz infinitytier-ceaef19fb70523852441c8dd3ba647fa6ad217b9.zip |
Fix for GitHub issue #260 -- fix for (non-exploitable) crash in network preferred relay code
Diffstat (limited to 'node')
-rw-r--r-- | node/Peer.hpp | 1 | ||||
-rw-r--r-- | node/Switch.cpp | 10 |
2 files changed, 6 insertions, 5 deletions
diff --git a/node/Peer.hpp b/node/Peer.hpp index 7b8d18ea..5816db69 100644 --- a/node/Peer.hpp +++ b/node/Peer.hpp @@ -263,7 +263,6 @@ public: return (l * (((unsigned int)tsr / (ZT_PEER_DIRECT_PING_DELAY + 1000)) + 1)); } - /** * Update latency with a new direct measurment * diff --git a/node/Switch.cpp b/node/Switch.cpp index 74e2f4c6..bf0d1aff 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -820,10 +820,12 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) for(std::vector< std::pair<Address,InetAddress> >::const_iterator r(nconf->relays().begin());r!=nconf->relays().end();++r) { if (r->first != peer->address()) { SharedPtr<Peer> rp(RR->topology->getPeer(r->first)); - const unsigned int q = rp->relayQuality(now); - if ((rp)&&(q < bestq)) { // SUBTILE: < == don't use these if they are nil quality (unsigned int max), instead use a root - bestq = q; - rp.swap(relay); + if (rp) { + const unsigned int q = rp->relayQuality(now); + if (q < bestq) { // SUBTILE: < == don't use these if they are nil quality (unsigned int max), instead use a root + bestq = q; + rp.swap(relay); + } } } } |