diff --git a/node/Locator.cpp b/node/Locator.cpp index 9f5e0cc86..063205a9d 100644 --- a/node/Locator.cpp +++ b/node/Locator.cpp @@ -18,6 +18,16 @@ namespace ZeroTier { +Locator::Locator(const char *const str) noexcept +{ + if (!fromString(str)) { + m_ts = 0; + m_signer.zero(); + m_endpoints.clear(); + m_signature.clear(); + } +} + bool Locator::add(const Endpoint &ep) { if (m_endpoints.size() < ZT_LOCATOR_MAX_ENDPOINTS) { diff --git a/node/Locator.hpp b/node/Locator.hpp index 28d839348..772304cc0 100644 --- a/node/Locator.hpp +++ b/node/Locator.hpp @@ -44,6 +44,8 @@ public: m_ts(0) {} + explicit Locator(const char *const str) noexcept; + ZT_INLINE Locator(const Locator &loc) noexcept : m_ts(loc.m_ts), m_signer(loc.m_signer), diff --git a/node/Node.cpp b/node/Node.cpp index 25b8bcef0..f07d8bc47 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -124,8 +124,9 @@ Node::Node(void *uPtr, void *tPtr, const struct ZT_Node_Callbacks *callbacks, in for(unsigned int i=0;i<1023;++i) RR->randomPrivilegedPortOrder[i] = (uint16_t)(i + 1); for(unsigned int i=0;i<512;++i) { - const unsigned int a = (unsigned int)Utils::random() % 1023; - const unsigned int b = (unsigned int)Utils::random() % 1023; + uint64_t rn = Utils::random(); + const unsigned int a = (unsigned int)rn % 1023; + const unsigned int b = (unsigned int)(rn >> 32U) % 1023; if (a != b) { const uint16_t tmp = RR->randomPrivilegedPortOrder[a]; RR->randomPrivilegedPortOrder[a] = RR->randomPrivilegedPortOrder[b];