Fix crash.

This commit is contained in:
Adam Ierymenko 2017-02-21 13:48:29 -08:00
parent 32f5a0ab18
commit 54fa73844c

View File

@ -1465,24 +1465,27 @@ void EmbeddedNetworkController::_request(
} }
for(unsigned long i=0;i<memberCapabilities.size();++i) { for(unsigned long i=0;i<memberCapabilities.size();++i) {
const uint64_t capId = OSUtils::jsonInt(memberCapabilities[i],0ULL) & 0xffffffffULL; const uint64_t capId = OSUtils::jsonInt(memberCapabilities[i],0ULL) & 0xffffffffULL;
json *cap = capsById[capId]; std::map< uint64_t,json * >::const_iterator ctmp = capsById.find(capId);
if ((cap->is_object())&&(cap->size() > 0)) { if (ctmp != capsById.end()) {
ZT_VirtualNetworkRule capr[ZT_MAX_CAPABILITY_RULES]; json *cap = ctmp->second;
unsigned int caprc = 0; if ((cap)&&(cap->is_object())&&(cap->size() > 0)) {
json &caprj = (*cap)["rules"]; ZT_VirtualNetworkRule capr[ZT_MAX_CAPABILITY_RULES];
if ((caprj.is_array())&&(caprj.size() > 0)) { unsigned int caprc = 0;
for(unsigned long j=0;j<caprj.size();++j) { json &caprj = (*cap)["rules"];
if (caprc >= ZT_MAX_CAPABILITY_RULES) if ((caprj.is_array())&&(caprj.size() > 0)) {
break; for(unsigned long j=0;j<caprj.size();++j) {
if (_parseRule(caprj[j],capr[caprc])) if (caprc >= ZT_MAX_CAPABILITY_RULES)
++caprc; break;
if (_parseRule(caprj[j],capr[caprc]))
++caprc;
}
} }
nc.capabilities[nc.capabilityCount] = Capability((uint32_t)capId,nwid,now,1,capr,caprc);
if (nc.capabilities[nc.capabilityCount].sign(_signingId,identity.address()))
++nc.capabilityCount;
if (nc.capabilityCount >= ZT_MAX_NETWORK_CAPABILITIES)
break;
} }
nc.capabilities[nc.capabilityCount] = Capability((uint32_t)capId,nwid,now,1,capr,caprc);
if (nc.capabilities[nc.capabilityCount].sign(_signingId,identity.address()))
++nc.capabilityCount;
if (nc.capabilityCount >= ZT_MAX_NETWORK_CAPABILITIES)
break;
} }
} }