Skip to content

Commit a372619

Browse files
authored
Fix addIp being called with applied ips (zerotier#1897)
This was getting called outside of the check for existing ips Because of the added ifdef and a brace getting moved to the wrong place. ``` if (! n.tap()->addIp(*ip)) { fprintf(stderr, "ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString(ipbuf)); } WinFWHelper::newICMPRule(*ip, n.config().nwid); ```
1 parent 12cdf39 commit a372619

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

service/OneService.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,8 +2307,10 @@ class OneServiceImpl : public OneService
23072307
auto same_subnet = [ip](InetAddress i){
23082308
return ip->network() == i.network();
23092309
};
2310+
#endif
23102311

23112312
if (std::find(n.managedIps().begin(),n.managedIps().end(),*ip) == n.managedIps().end()) {
2313+
#ifdef __APPLE__
23122314
// if same subnet as a previously added address
23132315
if (
23142316
std::find_if(n.managedIps().begin(),n.managedIps().end(), same_subnet) != n.managedIps().end() ||
@@ -2322,15 +2324,17 @@ class OneServiceImpl : public OneService
23222324
} else {
23232325
newManagedIps2.push_back(*ip);
23242326
}
2325-
}
23262327
#endif
23272328

2328-
if (!n.tap()->addIp(*ip))
2329-
fprintf(stderr,"ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString(ipbuf));
2330-
2331-
#ifdef __WINDOWS__
2332-
WinFWHelper::newICMPRule(*ip, n.config().nwid);
2333-
#endif
2329+
if (! n.tap()->addIp(*ip)) {
2330+
fprintf(stderr, "ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString(ipbuf));
2331+
}
2332+
else {
2333+
#ifdef __WINDOWS__
2334+
WinFWHelper::newICMPRule(*ip, n.config().nwid);
2335+
#endif
2336+
}
2337+
}
23342338
}
23352339

23362340
#ifdef __APPLE__

0 commit comments

Comments
 (0)