From 1a896949804f60161118b742cadd2bf9c290420b Mon Sep 17 00:00:00 2001 From: Michael Aldridge Date: Wed, 6 Jul 2016 02:38:23 -0500 Subject: [PATCH 1/6] Remove explicit sys/sysctl.h includes Explicitly including sys/sysctl.h breaks the ability to build against muslc. --- attic/OSXEthernetTap.cpp.pcap-with-bridge-test | 1 - attic/OSXEthernetTap.cpp.utun-work-in-progress | 1 - ext/libnatpmp/getgateway.c | 1 - osdep/BSDEthernetTap.cpp | 1 - osdep/ManagedRoute.cpp | 1 - osdep/OSXEthernetTap.cpp | 1 - 6 files changed, 6 deletions(-) diff --git a/attic/OSXEthernetTap.cpp.pcap-with-bridge-test b/attic/OSXEthernetTap.cpp.pcap-with-bridge-test index 60194421c..baae0a4b3 100644 --- a/attic/OSXEthernetTap.cpp.pcap-with-bridge-test +++ b/attic/OSXEthernetTap.cpp.pcap-with-bridge-test @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/attic/OSXEthernetTap.cpp.utun-work-in-progress b/attic/OSXEthernetTap.cpp.utun-work-in-progress index b7a05334d..f40483e8c 100644 --- a/attic/OSXEthernetTap.cpp.utun-work-in-progress +++ b/attic/OSXEthernetTap.cpp.utun-work-in-progress @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/ext/libnatpmp/getgateway.c b/ext/libnatpmp/getgateway.c index dfb9f3e21..7f3141521 100644 --- a/ext/libnatpmp/getgateway.c +++ b/ext/libnatpmp/getgateway.c @@ -96,7 +96,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef USE_SYSCTL_NET_ROUTE #include -#include #include #include #endif diff --git a/osdep/BSDEthernetTap.cpp b/osdep/BSDEthernetTap.cpp index 3e0c22642..e8d36c9c5 100644 --- a/osdep/BSDEthernetTap.cpp +++ b/osdep/BSDEthernetTap.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/osdep/ManagedRoute.cpp b/osdep/ManagedRoute.cpp index 549901224..b87506c07 100644 --- a/osdep/ManagedRoute.cpp +++ b/osdep/ManagedRoute.cpp @@ -33,7 +33,6 @@ #ifdef __UNIX_LIKE__ #include #include -#include #include #include #include diff --git a/osdep/OSXEthernetTap.cpp b/osdep/OSXEthernetTap.cpp index e8c5c1eac..89cbbdac3 100644 --- a/osdep/OSXEthernetTap.cpp +++ b/osdep/OSXEthernetTap.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include From 8a15b42dabbacd522bfc7c2042591fa71692136c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 14 Jul 2016 19:29:00 -0700 Subject: [PATCH 2/6] switch to GCC for Android --- java/jni/Application.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/jni/Application.mk b/java/jni/Application.mk index 608e94c0a..6950c0e65 100644 --- a/java/jni/Application.mk +++ b/java/jni/Application.mk @@ -1,5 +1,5 @@ -NDK_TOOLCHAIN_VERSION := clang -APP_STL := c++_static -APP_CPPFLAGS := -O3 -fPIC -fPIE -fvectorize -Wall -fstack-protector -fexceptions -fno-strict-aliasing -Wno-deprecated-register -DZT_NO_TYPE_PUNNING=1 +# NDK_TOOLCHAIN_VERSION := clang3.5 +APP_STL := gnustl_static +APP_CPPFLAGS := -O3 -fPIC -fPIE -Wall -fstack-protector -fexceptions -fno-strict-aliasing -Wno-deprecated-register -DZT_NO_TYPE_PUNNING=1 APP_PLATFORM := android-14 APP_ABI := all From bcdd158ad81ee4aedb898c05a11219a7b50e6306 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Thu, 21 Jul 2016 22:41:02 +0200 Subject: [PATCH 3/6] C++11 requires a space between literal and string macro --- one.cpp | 168 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/one.cpp b/one.cpp index 6bd5a34d8..9f7a0a29d 100644 --- a/one.cpp +++ b/one.cpp @@ -97,21 +97,21 @@ static void cliPrintHelp(const char *pn,FILE *out) fprintf(out, COPYRIGHT_NOTICE ZT_EOL_S LICENSE_GRANT ZT_EOL_S); - fprintf(out,"Usage: %s [-switches] []"ZT_EOL_S""ZT_EOL_S,pn); - fprintf(out,"Available switches:"ZT_EOL_S); - fprintf(out," -h - Display this help"ZT_EOL_S); - fprintf(out," -v - Show version"ZT_EOL_S); - fprintf(out," -j - Display full raw JSON output"ZT_EOL_S); - fprintf(out," -D - ZeroTier home path for parameter auto-detect"ZT_EOL_S); - fprintf(out," -p - HTTP port (default: auto)"ZT_EOL_S); - fprintf(out," -T - Authentication token (default: auto)"ZT_EOL_S); - fprintf(out,ZT_EOL_S"Available commands:"ZT_EOL_S); - fprintf(out," info - Display status info"ZT_EOL_S); - fprintf(out," listpeers - List all peers"ZT_EOL_S); - fprintf(out," listnetworks - List all networks"ZT_EOL_S); - fprintf(out," join - Join a network"ZT_EOL_S); - fprintf(out," leave - Leave a network"ZT_EOL_S); - fprintf(out," set - Set a network setting"ZT_EOL_S); + fprintf(out,"Usage: %s [-switches] []" ZT_EOL_S"" ZT_EOL_S,pn); + fprintf(out,"Available switches:" ZT_EOL_S); + fprintf(out," -h - Display this help" ZT_EOL_S); + fprintf(out," -v - Show version" ZT_EOL_S); + fprintf(out," -j - Display full raw JSON output" ZT_EOL_S); + fprintf(out," -D - ZeroTier home path for parameter auto-detect" ZT_EOL_S); + fprintf(out," -p - HTTP port (default: auto)" ZT_EOL_S); + fprintf(out," -T - Authentication token (default: auto)" ZT_EOL_S); + fprintf(out,ZT_EOL_S"Available commands:" ZT_EOL_S); + fprintf(out," info - Display status info" ZT_EOL_S); + fprintf(out," listpeers - List all peers" ZT_EOL_S); + fprintf(out," listnetworks - List all networks" ZT_EOL_S); + fprintf(out," join - Join a network" ZT_EOL_S); + fprintf(out," leave - Leave a network" ZT_EOL_S); + fprintf(out," set - Set a network setting" ZT_EOL_S); } static std::string cliFixJsonCRs(const std::string &s) @@ -194,7 +194,7 @@ static int cli(int argc,char **argv) cliPrintHelp(argv[0],stdout); return 1; } - printf("%d.%d.%d"ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION); + printf("%d.%d.%d" ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION); return 0; case 'h': @@ -216,7 +216,7 @@ static int cli(int argc,char **argv) if ((!port)||(!authToken.length())) { if (!homeDir.length()) { - fprintf(stderr,"%s: missing port or authentication token and no home directory specified to auto-detect"ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: missing port or authentication token and no home directory specified to auto-detect" ZT_EOL_S,argv[0]); return 2; } @@ -225,7 +225,7 @@ static int cli(int argc,char **argv) OSUtils::readFile((homeDir + ZT_PATH_SEPARATOR_S + "zerotier-one.port").c_str(),portStr); port = Utils::strToUInt(portStr.c_str()); if ((port == 0)||(port > 0xffff)) { - fprintf(stderr,"%s: missing port and zerotier-one.port not found in %s"ZT_EOL_S,argv[0],homeDir.c_str()); + fprintf(stderr,"%s: missing port and zerotier-one.port not found in %s" ZT_EOL_S,argv[0],homeDir.c_str()); return 2; } } @@ -247,7 +247,7 @@ static int cli(int argc,char **argv) } #endif if (!authToken.length()) { - fprintf(stderr,"%s: missing authentication token and authtoken.secret not found (or readable) in %s"ZT_EOL_S,argv[0],homeDir.c_str()); + fprintf(stderr,"%s: missing authentication token and authtoken.secret not found (or readable) in %s" ZT_EOL_S,argv[0],homeDir.c_str()); return 2; } } @@ -279,7 +279,7 @@ static int cli(int argc,char **argv) printf("%s",cliFixJsonCRs(responseBody).c_str()); return 0; } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } else if ((command == "info")||(command == "status")) { @@ -312,7 +312,7 @@ static int cli(int argc,char **argv) online = (j->u.object.values[k].value->u.boolean != 0); } if ((address)&&(version)) { - printf("200 info %s %s %s"ZT_EOL_S,address,(online ? "ONLINE" : "OFFLINE"),version); + printf("200 info %s %s %s" ZT_EOL_S,address,(online ? "ONLINE" : "OFFLINE"),version); good = true; } } @@ -321,12 +321,12 @@ static int cli(int argc,char **argv) if (good) { return 0; } else { - printf("%u %s invalid JSON response"ZT_EOL_S,scode,command.c_str()); + printf("%u %s invalid JSON response" ZT_EOL_S,scode,command.c_str()); return 1; } } } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } else if (command == "listpeers") { @@ -343,7 +343,7 @@ static int cli(int argc,char **argv) printf("%s",cliFixJsonCRs(responseBody).c_str()); return 0; } else { - printf("200 listpeers "ZT_EOL_S); + printf("200 listpeers " ZT_EOL_S); json_value *j = json_parse(responseBody.c_str(),responseBody.length()); if (j) { if (j->type == json_array) { @@ -417,7 +417,7 @@ static int cli(int argc,char **argv) verstr[0] = '-'; verstr[1] = (char)0; } - printf("200 listpeers %s %s %lld %s %s"ZT_EOL_S,address,(paths.length()) ? paths.c_str() : "-",(long long)latency,verstr,role); + printf("200 listpeers %s %s %lld %s %s" ZT_EOL_S,address,(paths.length()) ? paths.c_str() : "-",(long long)latency,verstr,role); } } } @@ -427,7 +427,7 @@ static int cli(int argc,char **argv) return 0; } } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } else if (command == "listnetworks") { @@ -444,7 +444,7 @@ static int cli(int argc,char **argv) printf("%s",cliFixJsonCRs(responseBody).c_str()); return 0; } else { - printf("200 listnetworks "ZT_EOL_S); + printf("200 listnetworks " ZT_EOL_S); json_value *j = json_parse(responseBody.c_str(),responseBody.length()); if (j) { if (j->type == json_array) { @@ -483,7 +483,7 @@ static int cli(int argc,char **argv) } } if ((nwid)&&(mac)&&(status)&&(type)) { - printf("200 listnetworks %s %s %s %s %s %s %s"ZT_EOL_S, + printf("200 listnetworks %s %s %s %s %s %s %s" ZT_EOL_S, nwid, (((name)&&(name[0])) ? name : "-"), mac, @@ -499,7 +499,7 @@ static int cli(int argc,char **argv) } } } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } else if (command == "join") { @@ -523,11 +523,11 @@ static int cli(int argc,char **argv) if (json) { printf("%s",cliFixJsonCRs(responseBody).c_str()); } else { - printf("200 join OK"ZT_EOL_S); + printf("200 join OK" ZT_EOL_S); } return 0; } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } else if (command == "leave") { @@ -547,11 +547,11 @@ static int cli(int argc,char **argv) if (json) { printf("%s",cliFixJsonCRs(responseBody).c_str()); } else { - printf("200 leave OK"ZT_EOL_S); + printf("200 leave OK" ZT_EOL_S); } return 0; } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } else if (command == "set") { @@ -584,7 +584,7 @@ static int cli(int argc,char **argv) printf("%s",cliFixJsonCRs(responseBody).c_str()); return 0; } else { - printf("%u %s %s"ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); + printf("%u %s %s" ZT_EOL_S,scode,command.c_str(),responseBody.c_str()); return 1; } } @@ -613,13 +613,13 @@ static void idtoolPrintHelp(FILE *out,const char *pn) fprintf(out, COPYRIGHT_NOTICE ZT_EOL_S LICENSE_GRANT ZT_EOL_S); - fprintf(out,"Usage: %s []"ZT_EOL_S""ZT_EOL_S"Commands:"ZT_EOL_S,pn); - fprintf(out," generate [] [] []"ZT_EOL_S); - fprintf(out," validate "ZT_EOL_S); - fprintf(out," getpublic "ZT_EOL_S); - fprintf(out," sign "ZT_EOL_S); - fprintf(out," verify "ZT_EOL_S); - fprintf(out," mkcom [ ...] (hexadecimal integers)"ZT_EOL_S); + fprintf(out,"Usage: %s []" ZT_EOL_S"" ZT_EOL_S"Commands:" ZT_EOL_S,pn); + fprintf(out," generate [] [] []" ZT_EOL_S); + fprintf(out," validate " ZT_EOL_S); + fprintf(out," getpublic " ZT_EOL_S); + fprintf(out," sign " ZT_EOL_S); + fprintf(out," verify " ZT_EOL_S); + fprintf(out," mkcom [ ...] (hexadecimal integers)" ZT_EOL_S); } static Identity getIdFromArg(char *arg) @@ -675,15 +675,15 @@ static int idtool(int argc,char **argv) std::string idser = id.toString(true); if (argc >= 3) { if (!OSUtils::writeFile(argv[2],idser)) { - fprintf(stderr,"Error writing to %s"ZT_EOL_S,argv[2]); + fprintf(stderr,"Error writing to %s" ZT_EOL_S,argv[2]); return 1; - } else printf("%s written"ZT_EOL_S,argv[2]); + } else printf("%s written" ZT_EOL_S,argv[2]); if (argc >= 4) { idser = id.toString(false); if (!OSUtils::writeFile(argv[3],idser)) { - fprintf(stderr,"Error writing to %s"ZT_EOL_S,argv[3]); + fprintf(stderr,"Error writing to %s" ZT_EOL_S,argv[3]); return 1; - } else printf("%s written"ZT_EOL_S,argv[3]); + } else printf("%s written" ZT_EOL_S,argv[3]); } } else printf("%s",idser.c_str()); } else if (!strcmp(argv[1],"validate")) { @@ -694,14 +694,14 @@ static int idtool(int argc,char **argv) Identity id = getIdFromArg(argv[2]); if (!id) { - fprintf(stderr,"Identity argument invalid or file unreadable: %s"ZT_EOL_S,argv[2]); + fprintf(stderr,"Identity argument invalid or file unreadable: %s" ZT_EOL_S,argv[2]); return 1; } if (!id.locallyValidate()) { - fprintf(stderr,"%s FAILED validation."ZT_EOL_S,argv[2]); + fprintf(stderr,"%s FAILED validation." ZT_EOL_S,argv[2]); return 1; - } else printf("%s is a valid identity"ZT_EOL_S,argv[2]); + } else printf("%s is a valid identity" ZT_EOL_S,argv[2]); } else if (!strcmp(argv[1],"getpublic")) { if (argc < 3) { idtoolPrintHelp(stdout,argv[0]); @@ -710,7 +710,7 @@ static int idtool(int argc,char **argv) Identity id = getIdFromArg(argv[2]); if (!id) { - fprintf(stderr,"Identity argument invalid or file unreadable: %s"ZT_EOL_S,argv[2]); + fprintf(stderr,"Identity argument invalid or file unreadable: %s" ZT_EOL_S,argv[2]); return 1; } @@ -723,18 +723,18 @@ static int idtool(int argc,char **argv) Identity id = getIdFromArg(argv[2]); if (!id) { - fprintf(stderr,"Identity argument invalid or file unreadable: %s"ZT_EOL_S,argv[2]); + fprintf(stderr,"Identity argument invalid or file unreadable: %s" ZT_EOL_S,argv[2]); return 1; } if (!id.hasPrivate()) { - fprintf(stderr,"%s does not contain a private key (must use private to sign)"ZT_EOL_S,argv[2]); + fprintf(stderr,"%s does not contain a private key (must use private to sign)" ZT_EOL_S,argv[2]); return 1; } std::string inf; if (!OSUtils::readFile(argv[3],inf)) { - fprintf(stderr,"%s is not readable"ZT_EOL_S,argv[3]); + fprintf(stderr,"%s is not readable" ZT_EOL_S,argv[3]); return 1; } C25519::Signature signature = id.sign(inf.data(),(unsigned int)inf.length()); @@ -747,21 +747,21 @@ static int idtool(int argc,char **argv) Identity id = getIdFromArg(argv[2]); if (!id) { - fprintf(stderr,"Identity argument invalid or file unreadable: %s"ZT_EOL_S,argv[2]); + fprintf(stderr,"Identity argument invalid or file unreadable: %s" ZT_EOL_S,argv[2]); return 1; } std::string inf; if (!OSUtils::readFile(argv[3],inf)) { - fprintf(stderr,"%s is not readable"ZT_EOL_S,argv[3]); + fprintf(stderr,"%s is not readable" ZT_EOL_S,argv[3]); return 1; } std::string signature(Utils::unhex(argv[4])); if ((signature.length() > ZT_ADDRESS_LENGTH)&&(id.verify(inf.data(),(unsigned int)inf.length(),signature.data(),(unsigned int)signature.length()))) { - printf("%s signature valid"ZT_EOL_S,argv[3]); + printf("%s signature valid" ZT_EOL_S,argv[3]); } else { - fprintf(stderr,"%s signature check FAILED"ZT_EOL_S,argv[3]); + fprintf(stderr,"%s signature check FAILED" ZT_EOL_S,argv[3]); return 1; } } else if (!strcmp(argv[1],"mkcom")) { @@ -772,7 +772,7 @@ static int idtool(int argc,char **argv) Identity id = getIdFromArg(argv[2]); if ((!id)||(!id.hasPrivate())) { - fprintf(stderr,"Identity argument invalid, does not include private key, or file unreadable: %s"ZT_EOL_S,argv[2]); + fprintf(stderr,"Identity argument invalid, does not include private key, or file unreadable: %s" ZT_EOL_S,argv[2]); return 1; } @@ -787,7 +787,7 @@ static int idtool(int argc,char **argv) } } if (!com.sign(id)) { - fprintf(stderr,"Signature of certificate of membership failed."ZT_EOL_S); + fprintf(stderr,"Signature of certificate of membership failed." ZT_EOL_S); return 1; } @@ -981,27 +981,27 @@ static void printHelp(const char *cn,FILE *out) LICENSE_GRANT ZT_EOL_S); std::string updateUrl(OneService::autoUpdateUrl()); if (updateUrl.length()) - fprintf(out,"Automatic updates enabled:"ZT_EOL_S" %s"ZT_EOL_S" (all updates are securely authenticated by 256-bit ECDSA signature)"ZT_EOL_S""ZT_EOL_S,updateUrl.c_str()); - fprintf(out,"Usage: %s [-switches] [home directory]"ZT_EOL_S""ZT_EOL_S,cn); - fprintf(out,"Available switches:"ZT_EOL_S); - fprintf(out," -h - Display this help"ZT_EOL_S); - fprintf(out," -v - Show version"ZT_EOL_S); - fprintf(out," -U - Run as unprivileged user (skip privilege check)"ZT_EOL_S); - fprintf(out," -p - Port for UDP and TCP/HTTP (default: 9993, 0 for random)"ZT_EOL_S); + fprintf(out,"Automatic updates enabled:" ZT_EOL_S" %s" ZT_EOL_S" (all updates are securely authenticated by 256-bit ECDSA signature)" ZT_EOL_S"" ZT_EOL_S,updateUrl.c_str()); + fprintf(out,"Usage: %s [-switches] [home directory]" ZT_EOL_S"" ZT_EOL_S,cn); + fprintf(out,"Available switches:" ZT_EOL_S); + fprintf(out," -h - Display this help" ZT_EOL_S); + fprintf(out," -v - Show version" ZT_EOL_S); + fprintf(out," -U - Run as unprivileged user (skip privilege check)" ZT_EOL_S); + fprintf(out," -p - Port for UDP and TCP/HTTP (default: 9993, 0 for random)" ZT_EOL_S); #ifdef __UNIX_LIKE__ - fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S); + fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)" ZT_EOL_S); #endif // __UNIX_LIKE__ #ifdef __WINDOWS__ - fprintf(out," -C - Run from command line instead of as service (Windows)"ZT_EOL_S); - fprintf(out," -I - Install Windows service (Windows)"ZT_EOL_S); - fprintf(out," -R - Uninstall Windows service (Windows)"ZT_EOL_S); - fprintf(out," -D - Remove all instances of Windows tap device (Windows)"ZT_EOL_S); + fprintf(out," -C - Run from command line instead of as service (Windows)" ZT_EOL_S); + fprintf(out," -I - Install Windows service (Windows)" ZT_EOL_S); + fprintf(out," -R - Uninstall Windows service (Windows)" ZT_EOL_S); + fprintf(out," -D - Remove all instances of Windows tap device (Windows)" ZT_EOL_S); #endif // __WINDOWS__ - fprintf(out," -i - Generate and manage identities (zerotier-idtool)"ZT_EOL_S); - fprintf(out," -q - Query API (zerotier-cli)"ZT_EOL_S); + fprintf(out," -i - Generate and manage identities (zerotier-idtool)" ZT_EOL_S); + fprintf(out," -q - Query API (zerotier-cli)" ZT_EOL_S); } #ifdef __WINDOWS__ @@ -1079,7 +1079,7 @@ int main(int argc,char **argv) break; case 'v': // Display version - printf("%d.%d.%d"ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION); + printf("%d.%d.%d" ZT_EOL_S,ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION); return 0; case 'i': // Invoke idtool personality @@ -1101,12 +1101,12 @@ int main(int argc,char **argv) case 'I': { // Install this binary as a Windows service if (IsCurrentUserLocalAdministrator() != TRUE) { - fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: must be run as a local administrator." ZT_EOL_S,argv[0]); return 1; } std::string ret(InstallService(ZT_SERVICE_NAME,ZT_SERVICE_DISPLAY_NAME,ZT_SERVICE_START_TYPE,ZT_SERVICE_DEPENDENCIES,ZT_SERVICE_ACCOUNT,ZT_SERVICE_PASSWORD)); if (ret.length()) { - fprintf(stderr,"%s: unable to install service: %s"ZT_EOL_S,argv[0],ret.c_str()); + fprintf(stderr,"%s: unable to install service: %s" ZT_EOL_S,argv[0],ret.c_str()); return 3; } return 0; @@ -1114,12 +1114,12 @@ int main(int argc,char **argv) case 'R': { // Uninstall this binary as Windows service if (IsCurrentUserLocalAdministrator() != TRUE) { - fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: must be run as a local administrator." ZT_EOL_S,argv[0]); return 1; } std::string ret(UninstallService(ZT_SERVICE_NAME)); if (ret.length()) { - fprintf(stderr,"%s: unable to uninstall service: %s"ZT_EOL_S,argv[0],ret.c_str()); + fprintf(stderr,"%s: unable to uninstall service: %s" ZT_EOL_S,argv[0],ret.c_str()); return 3; } return 0; @@ -1128,7 +1128,7 @@ int main(int argc,char **argv) case 'D': { std::string err = WindowsEthernetTap::destroyAllPersistentTapDevices(); if (err.length() > 0) { - fprintf(stderr,"%s: unable to uninstall one or more persistent tap devices: %s"ZT_EOL_S,argv[0],err.c_str()); + fprintf(stderr,"%s: unable to uninstall one or more persistent tap devices: %s" ZT_EOL_S,argv[0],err.c_str()); return 3; } return 0; @@ -1154,7 +1154,7 @@ int main(int argc,char **argv) if (!homeDir.length()) homeDir = OneService::platformDefaultHomePath(); if (!homeDir.length()) { - fprintf(stderr,"%s: no home path specified and no platform default available"ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: no home path specified and no platform default available" ZT_EOL_S,argv[0]); return 1; } else { std::vector hpsp(Utils::split(homeDir.c_str(),ZT_PATH_SEPARATOR_S,"","")); @@ -1175,14 +1175,14 @@ int main(int argc,char **argv) #ifdef __UNIX_LIKE__ #ifndef ZT_ONE_NO_ROOT_CHECK if ((!skipRootCheck)&&(getuid() != 0)) { - fprintf(stderr,"%s: must be run as root (uid 0)"ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: must be run as root (uid 0)" ZT_EOL_S,argv[0]); return 1; } #endif // !ZT_ONE_NO_ROOT_CHECK if (runAsDaemon) { long p = (long)fork(); if (p < 0) { - fprintf(stderr,"%s: could not fork"ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: could not fork" ZT_EOL_S,argv[0]); return 1; } else if (p > 0) return 0; // forked @@ -1199,7 +1199,7 @@ int main(int argc,char **argv) // Running in "interactive" mode (mostly for debugging) if (IsCurrentUserLocalAdministrator() != TRUE) { if (!skipRootCheck) { - fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: must be run as a local administrator." ZT_EOL_S,argv[0]); return 1; } } else { @@ -1214,7 +1214,7 @@ int main(int argc,char **argv) if (CServiceBase::Run(zt1Service) == TRUE) { return 0; } else { - fprintf(stderr,"%s: unable to start service (try -h for help)"ZT_EOL_S,argv[0]); + fprintf(stderr,"%s: unable to start service (try -h for help)" ZT_EOL_S,argv[0]); return 1; } } @@ -1241,7 +1241,7 @@ int main(int argc,char **argv) case OneService::ONE_NORMAL_TERMINATION: break; case OneService::ONE_UNRECOVERABLE_ERROR: - fprintf(stderr,"%s: fatal error: %s"ZT_EOL_S,argv[0],zt1Service->fatalErrorMessage().c_str()); + fprintf(stderr,"%s: fatal error: %s" ZT_EOL_S,argv[0],zt1Service->fatalErrorMessage().c_str()); returnValue = 1; break; case OneService::ONE_IDENTITY_COLLISION: { From b3073f44a2180b2a888ae8615d6112bbd82ef3da Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Thu, 21 Jul 2016 23:02:54 +0200 Subject: [PATCH 4/6] move sourceAddress out of scope sourceAddress is used in the catch block --- node/IncomingPacket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 231f0d062..37af8425e 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -42,9 +42,9 @@ namespace ZeroTier { bool IncomingPacket::tryDecode(const RuntimeEnvironment *RR,bool deferred) { - try { - const Address sourceAddress(source()); + const Address sourceAddress(source()); + try { // Check for trusted paths or unencrypted HELLOs (HELLO is the only packet sent in the clear) const unsigned int c = cipher(); bool trusted = false; From 76b785c90fe08eb4bfb08de35e4ddb290ece9362 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Thu, 21 Jul 2016 23:08:55 +0200 Subject: [PATCH 5/6] fix _FORTIFY_SOURCE warning warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp] --- make-linux.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make-linux.mk b/make-linux.mk index 13b154763..acc22a635 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -98,8 +98,8 @@ endif ifeq ($(ZT_DEBUG),1) DEFS+=-DZT_TRACE - override CFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS) - override CXXFLAGS+=-Wall -g -pthread $(INCLUDES) $(DEFS) + override CFLAGS+=-Wall -g -O -pthread $(INCLUDES) $(DEFS) + override CXXFLAGS+=-Wall -g -O -pthread $(INCLUDES) $(DEFS) LDFLAGS= STRIP?=echo # The following line enables optimization for the crypto code, since From f21af60a136940b4da6823cb6b34e2368662c37c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 21 Jul 2016 19:05:14 -0700 Subject: [PATCH 6/6] Init trusted path count to zero. Meh. --- node/Topology.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/node/Topology.cpp b/node/Topology.cpp index 4105eae92..6e96f2eb7 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -44,6 +44,7 @@ static const unsigned char ZT_DEFAULT_WORLD[ZT_DEFAULT_WORLD_LENGTH] = {0x01,0x0 Topology::Topology(const RuntimeEnvironment *renv) : RR(renv), + _trustedPathCount(0), _amRoot(false) { std::string alls(RR->node->dataStoreGet("peers.save"));