From ce2338c24a46558a2e0fdb7ebbcf2e6ce9c8b615 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 13 Jun 2019 12:52:38 -0700 Subject: Fix null ptr on managed routes if no IPs are set. --- service/OneService.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'service') diff --git a/service/OneService.cpp b/service/OneService.cpp index 17f7debc..b3d6739a 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -190,6 +190,8 @@ namespace ZeroTier { namespace { +static const InetAddress NULL_INET_ADDR; + // Fake TLS hello for TCP tunnel outgoing connections (TUNNELED mode) static const char ZT_TCP_TUNNEL_HELLO[9] = { 0x17,0x03,0x03,0x00,0x04,(char)ZEROTIER_ONE_VERSION_MAJOR,(char)ZEROTIER_ONE_VERSION_MINOR,(char)((ZEROTIER_ONE_VERSION_REVISION >> 8) & 0xff),(char)(ZEROTIER_ONE_VERSION_REVISION & 0xff) }; @@ -1855,7 +1857,7 @@ public: const InetAddress *const target = reinterpret_cast(&(n.config.routes[i].target)); const InetAddress *const via = reinterpret_cast(&(n.config.routes[i].via)); - InetAddress *src = NULL; + const InetAddress *src = NULL; for (unsigned int j=0; j(&(n.config.assignedAddresses[j])); if (target->isV4() && tmp->isV4()) { @@ -1866,6 +1868,8 @@ public: break; } } + if (!src) + src = &NULL_INET_ADDR; if ( (!checkIfManagedIsAllowed(n,*target)) || ((via->ss_family == target->ss_family)&&(matchIpOnly(myIps,*via))) ) continue; -- cgit v1.2.3