From 60366386ca1f1192ceb2cba760220c123f53251e Mon Sep 17 00:00:00 2001 From: Ludvig Strigeus Date: Mon, 10 Dec 2018 23:31:47 +0100 Subject: [PATCH] Some small style fixes --- stdafx.h | 4 +--- tunsafe_ipaddr.h | 1 + wireguard.cpp | 2 +- wireguard_config.cpp | 2 +- wireguard_proto.cpp | 4 ++-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/stdafx.h b/stdafx.h index e33fcda..0f7852a 100644 --- a/stdafx.h +++ b/stdafx.h @@ -15,12 +15,12 @@ #define _WINSOCK_DEPRECATED_NO_WARNINGS 1 #define _HAS_EXCEPTIONS 0 #define _CRT_SECURE_NO_WARNINGS 1 +#define NOMINMAX //#include #include #include -#undef max //#include #include #include @@ -38,5 +38,3 @@ #include #include -#undef min - diff --git a/tunsafe_ipaddr.h b/tunsafe_ipaddr.h index 62e7483..a1df939 100644 --- a/tunsafe_ipaddr.h +++ b/tunsafe_ipaddr.h @@ -11,6 +11,7 @@ #endif union IpAddr { + short int sin_family; sockaddr_in sin; sockaddr_in6 sin6; }; diff --git a/wireguard.cpp b/wireguard.cpp index e4e5fa4..5184e81 100644 --- a/wireguard.cpp +++ b/wireguard.cpp @@ -488,7 +488,7 @@ add_padding: inner_tag = WG_ACK_HEADER_COUNTER_4; } else { WriteLE32(write -= 4, (uint32)next_expected_packet); - WriteLE16(write -= 2, (uint16)(next_expected_packet>>32)); + WriteLE16(write -= 2, (uint16)(next_expected_packet >> 32)); inner_tag = WG_ACK_HEADER_COUNTER_6; } if (keypair->broadcast_short_key != 0) { diff --git a/wireguard_config.cpp b/wireguard_config.cpp index d5e25c0..b1f8226 100644 --- a/wireguard_config.cpp +++ b/wireguard_config.cpp @@ -402,7 +402,7 @@ void WgConfig::HandleConfigurationProtocolGet(WireguardProcessor *proc, std::str CmsgAppendFmt(result, "address=%s", PrintWgCidrAddr(x, buf)); for (WgPeer *peer = proc->dev_.peers_; peer; peer = peer->next_peer_) { - WG_SCOPED_LOCK(peer->lock_); + WG_SCOPED_LOCK(peer->mutex_); CmsgAppendHex(result, "public_key", peer->s_remote_.bytes, sizeof(peer->s_remote_)); if (!IsOnlyZeros(peer->preshared_key_, sizeof(peer->preshared_key_))) diff --git a/wireguard_proto.cpp b/wireguard_proto.cpp index 80d791a..49af3fb 100644 --- a/wireguard_proto.cpp +++ b/wireguard_proto.cpp @@ -927,8 +927,8 @@ bool WgPeer::ParseExtendedHandshake(WgKeypair *kp, const uint8 *data, size_t dat case EXT_BOOLEAN_FEATURES: if (WITH_BOOLEAN_FEATURES) { - for (size_t i = 0, j = std::max(WG_FEATURES_COUNT, size * 4); i != j; i++) { - uint8 value = (i < size * 4) ? (data[i >> 2] >> ((i * 2) & 7)) & 3 : 0; + for (uint32 i = 0, j = std::max(WG_FEATURES_COUNT, size * 4); i != j; i++) { + uint8 value = (i < (uint32)size * 4) ? (data[i >> 2] >> ((i * 2) & 7)) & 3 : 0; if (i >= WG_FEATURES_COUNT ? (value == WG_BOOLEAN_FEATURE_ENFORCES) : !ResolveBooleanFeatureValue(value, features_[i], &kp->enabled_features[i])) return false;