diff options
Diffstat (limited to 'controller')
-rw-r--r-- | controller/SqliteNetworkController.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp index eee9b7c7..62808de0 100644 --- a/controller/SqliteNetworkController.cpp +++ b/controller/SqliteNetworkController.cpp @@ -1769,13 +1769,15 @@ NetworkController::ResultCode SqliteNetworkController::_doNetworkConfigRequest(c std::sort(allowedEtherTypes.begin(),allowedEtherTypes.end()); allowedEtherTypes.erase(std::unique(allowedEtherTypes.begin(),allowedEtherTypes.end()),allowedEtherTypes.end()); - for(long i=0,k=0;((i<(long)allowedEtherTypes.size())&&(k<ZT_MAX_NETWORK_RULES));++i) { + for(long i=0;i<(long)allowedEtherTypes.size();++i) { + if ((nc.ruleCount + 2) > ZT_MAX_NETWORK_RULES) + break; if (allowedEtherTypes[i] > 0) { - nc.rules[k].t = ZT_NETWORK_RULE_MATCH_ETHERTYPE; - nc.rules[k].v.etherType = (uint16_t)allowedEtherTypes[i]; - ++k; + nc.rules[nc.ruleCount].t = ZT_NETWORK_RULE_MATCH_ETHERTYPE; + nc.rules[nc.ruleCount].v.etherType = (uint16_t)allowedEtherTypes[i]; + ++nc.ruleCount; } - nc.rules[k++].t = ZT_NETWORK_RULE_ACTION_ACCEPT; + nc.rules[nc.ruleCount++].t = ZT_NETWORK_RULE_ACTION_ACCEPT; } /* |