diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/service/sockets/sfdnsres.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/ssl/ssl_backend_schannel.cpp | 49 | ||||
| -rw-r--r-- | src/core/internal_network/network.cpp | 4 | ||||
| -rw-r--r-- | src/core/internal_network/network.h | 4 |
5 files changed, 35 insertions, 28 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d95d2fe01..4c53aed72 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -872,7 +872,7 @@ if(ENABLE_OPENSSL) | |||
| 872 | elseif (WIN32) | 872 | elseif (WIN32) |
| 873 | target_sources(core PRIVATE | 873 | target_sources(core PRIVATE |
| 874 | hle/service/ssl/ssl_backend_schannel.cpp) | 874 | hle/service/ssl/ssl_backend_schannel.cpp) |
| 875 | target_link_libraries(core PRIVATE Secur32) | 875 | target_link_libraries(core PRIVATE secur32) |
| 876 | else() | 876 | else() |
| 877 | target_sources(core PRIVATE | 877 | target_sources(core PRIVATE |
| 878 | hle/service/ssl/ssl_backend_none.cpp) | 878 | hle/service/ssl/ssl_backend_none.cpp) |
diff --git a/src/core/hle/service/sockets/sfdnsres.cpp b/src/core/hle/service/sockets/sfdnsres.cpp index fb8798b42..c5eaec920 100644 --- a/src/core/hle/service/sockets/sfdnsres.cpp +++ b/src/core/hle/service/sockets/sfdnsres.cpp | |||
| @@ -149,7 +149,7 @@ static std::pair<u32, GetAddrInfoError> GetHostByNameRequestImpl(HLERequestConte | |||
| 149 | const std::string host = Common::StringFromBuffer(host_buffer); | 149 | const std::string host = Common::StringFromBuffer(host_buffer); |
| 150 | // For now, ignore options, which are in input buffer 1 for GetHostByNameRequestWithOptions. | 150 | // For now, ignore options, which are in input buffer 1 for GetHostByNameRequestWithOptions. |
| 151 | 151 | ||
| 152 | auto res = Network::GetAddrInfo(host, /*service*/ std::nullopt); | 152 | auto res = Network::GetAddressInfo(host, /*service*/ std::nullopt); |
| 153 | if (!res.has_value()) { | 153 | if (!res.has_value()) { |
| 154 | return {0, Translate(res.error())}; | 154 | return {0, Translate(res.error())}; |
| 155 | } | 155 | } |
| @@ -249,7 +249,7 @@ static std::pair<u32, GetAddrInfoError> GetAddrInfoRequestImpl(HLERequestContext | |||
| 249 | 249 | ||
| 250 | // Serialized hints are also passed in a buffer, but are ignored for now. | 250 | // Serialized hints are also passed in a buffer, but are ignored for now. |
| 251 | 251 | ||
| 252 | auto res = Network::GetAddrInfo(host, service); | 252 | auto res = Network::GetAddressInfo(host, service); |
| 253 | if (!res.has_value()) { | 253 | if (!res.has_value()) { |
| 254 | return {0, Translate(res.error())}; | 254 | return {0, Translate(res.error())}; |
| 255 | } | 255 | } |
diff --git a/src/core/hle/service/ssl/ssl_backend_schannel.cpp b/src/core/hle/service/ssl/ssl_backend_schannel.cpp index 0a326b536..92b2dddaa 100644 --- a/src/core/hle/service/ssl/ssl_backend_schannel.cpp +++ b/src/core/hle/service/ssl/ssl_backend_schannel.cpp | |||
| @@ -12,29 +12,31 @@ | |||
| 12 | 12 | ||
| 13 | #include <mutex> | 13 | #include <mutex> |
| 14 | 14 | ||
| 15 | namespace { | ||
| 16 | |||
| 17 | // These includes are inside the namespace to avoid a conflict on MinGW where | ||
| 18 | // the headers define an enum containing Network and Service as enumerators | ||
| 19 | // (which clash with the correspondingly named namespaces). | ||
| 15 | #define SECURITY_WIN32 | 20 | #define SECURITY_WIN32 |
| 16 | #include <Security.h> | 21 | #include <security.h> |
| 17 | #include <schnlsp.h> | 22 | #include <schnlsp.h> |
| 18 | 23 | ||
| 19 | namespace { | ||
| 20 | |||
| 21 | std::once_flag one_time_init_flag; | 24 | std::once_flag one_time_init_flag; |
| 22 | bool one_time_init_success = false; | 25 | bool one_time_init_success = false; |
| 23 | 26 | ||
| 24 | SCHANNEL_CRED schannel_cred{ | 27 | SCHANNEL_CRED schannel_cred{}; |
| 25 | .dwVersion = SCHANNEL_CRED_VERSION, | 28 | CredHandle cred_handle; |
| 26 | .dwFlags = SCH_USE_STRONG_CRYPTO | // don't allow insecure protocols | 29 | |
| 27 | SCH_CRED_AUTO_CRED_VALIDATION | // validate certs | 30 | static void OneTimeInit() { |
| 28 | SCH_CRED_NO_DEFAULT_CREDS, // don't automatically present a client certificate | 31 | schannel_cred.dwVersion = SCHANNEL_CRED_VERSION; |
| 32 | schannel_cred.dwFlags = SCH_USE_STRONG_CRYPTO | // don't allow insecure protocols | ||
| 33 | SCH_CRED_AUTO_CRED_VALIDATION | // validate certs | ||
| 34 | SCH_CRED_NO_DEFAULT_CREDS; // don't automatically present a client certificate | ||
| 29 | // ^ I'm assuming that nobody would want to connect Yuzu to a | 35 | // ^ I'm assuming that nobody would want to connect Yuzu to a |
| 30 | // service that requires some OS-provided corporate client | 36 | // service that requires some OS-provided corporate client |
| 31 | // certificate, and presenting one to some arbitrary server | 37 | // certificate, and presenting one to some arbitrary server |
| 32 | // might be a privacy concern? Who knows, though. | 38 | // might be a privacy concern? Who knows, though. |
| 33 | }; | ||
| 34 | |||
| 35 | CredHandle cred_handle; | ||
| 36 | 39 | ||
| 37 | static void OneTimeInit() { | ||
| 38 | SECURITY_STATUS ret = | 40 | SECURITY_STATUS ret = |
| 39 | AcquireCredentialsHandle(nullptr, const_cast<LPTSTR>(UNISP_NAME), SECPKG_CRED_OUTBOUND, | 41 | AcquireCredentialsHandle(nullptr, const_cast<LPTSTR>(UNISP_NAME), SECPKG_CRED_OUTBOUND, |
| 40 | nullptr, &schannel_cred, nullptr, nullptr, &cred_handle, nullptr); | 42 | nullptr, &schannel_cred, nullptr, nullptr, &cred_handle, nullptr); |
| @@ -179,15 +181,21 @@ public: | |||
| 179 | // [1] (will be replaced by SECBUFFER_MISSING when SEC_E_INCOMPLETE_MESSAGE is | 181 | // [1] (will be replaced by SECBUFFER_MISSING when SEC_E_INCOMPLETE_MESSAGE is |
| 180 | // returned, or SECBUFFER_EXTRA when SEC_E_CONTINUE_NEEDED is returned if the | 182 | // returned, or SECBUFFER_EXTRA when SEC_E_CONTINUE_NEEDED is returned if the |
| 181 | // whole buffer wasn't used) | 183 | // whole buffer wasn't used) |
| 184 | .cbBuffer = 0, | ||
| 182 | .BufferType = SECBUFFER_EMPTY, | 185 | .BufferType = SECBUFFER_EMPTY, |
| 186 | .pvBuffer = nullptr, | ||
| 183 | }, | 187 | }, |
| 184 | }}; | 188 | }}; |
| 185 | std::array<SecBuffer, 2> output_buffers{{ | 189 | std::array<SecBuffer, 2> output_buffers{{ |
| 186 | { | 190 | { |
| 191 | .cbBuffer = 0, | ||
| 187 | .BufferType = SECBUFFER_TOKEN, | 192 | .BufferType = SECBUFFER_TOKEN, |
| 193 | .pvBuffer = nullptr, | ||
| 188 | }, // [0] | 194 | }, // [0] |
| 189 | { | 195 | { |
| 196 | .cbBuffer = 0, | ||
| 190 | .BufferType = SECBUFFER_ALERT, | 197 | .BufferType = SECBUFFER_ALERT, |
| 198 | .pvBuffer = nullptr, | ||
| 191 | }, // [1] | 199 | }, // [1] |
| 192 | }}; | 200 | }}; |
| 193 | SecBufferDesc input_desc{ | 201 | SecBufferDesc input_desc{ |
| @@ -299,21 +307,20 @@ public: | |||
| 299 | return read_size; | 307 | return read_size; |
| 300 | } | 308 | } |
| 301 | if (!ciphertext_read_buf_.empty()) { | 309 | if (!ciphertext_read_buf_.empty()) { |
| 310 | SecBuffer empty{ | ||
| 311 | .cbBuffer = 0, | ||
| 312 | .BufferType = SECBUFFER_EMPTY, | ||
| 313 | .pvBuffer = nullptr, | ||
| 314 | }; | ||
| 302 | std::array<SecBuffer, 5> buffers{{ | 315 | std::array<SecBuffer, 5> buffers{{ |
| 303 | { | 316 | { |
| 304 | .cbBuffer = static_cast<unsigned long>(ciphertext_read_buf_.size()), | 317 | .cbBuffer = static_cast<unsigned long>(ciphertext_read_buf_.size()), |
| 305 | .BufferType = SECBUFFER_DATA, | 318 | .BufferType = SECBUFFER_DATA, |
| 306 | .pvBuffer = ciphertext_read_buf_.data(), | 319 | .pvBuffer = ciphertext_read_buf_.data(), |
| 307 | }, | 320 | }, |
| 308 | { | 321 | empty, |
| 309 | .BufferType = SECBUFFER_EMPTY, | 322 | empty, |
| 310 | }, | 323 | empty, |
| 311 | { | ||
| 312 | .BufferType = SECBUFFER_EMPTY, | ||
| 313 | }, | ||
| 314 | { | ||
| 315 | .BufferType = SECBUFFER_EMPTY, | ||
| 316 | }, | ||
| 317 | }}; | 324 | }}; |
| 318 | ASSERT_OR_EXECUTE_MSG( | 325 | ASSERT_OR_EXECUTE_MSG( |
| 319 | buffers[0].cbBuffer == ciphertext_read_buf_.size(), | 326 | buffers[0].cbBuffer == ciphertext_read_buf_.size(), |
diff --git a/src/core/internal_network/network.cpp b/src/core/internal_network/network.cpp index 0164d12eb..40e451526 100644 --- a/src/core/internal_network/network.cpp +++ b/src/core/internal_network/network.cpp | |||
| @@ -493,9 +493,7 @@ u32 IPv4AddressToInteger(IPv4Address ip_addr) { | |||
| 493 | static_cast<u32>(ip_addr[2]) << 8 | static_cast<u32>(ip_addr[3]); | 493 | static_cast<u32>(ip_addr[2]) << 8 | static_cast<u32>(ip_addr[3]); |
| 494 | } | 494 | } |
| 495 | 495 | ||
| 496 | #undef GetAddrInfo // Windows defines it as a macro | 496 | Common::Expected<std::vector<AddrInfo>, GetAddrInfoError> GetAddressInfo( |
| 497 | |||
| 498 | Common::Expected<std::vector<AddrInfo>, GetAddrInfoError> GetAddrInfo( | ||
| 499 | const std::string& host, const std::optional<std::string>& service) { | 497 | const std::string& host, const std::optional<std::string>& service) { |
| 500 | addrinfo hints{}; | 498 | addrinfo hints{}; |
| 501 | hints.ai_family = AF_INET; // Switch only supports IPv4. | 499 | hints.ai_family = AF_INET; // Switch only supports IPv4. |
diff --git a/src/core/internal_network/network.h b/src/core/internal_network/network.h index 96319bfc8..badcb8369 100644 --- a/src/core/internal_network/network.h +++ b/src/core/internal_network/network.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <optional> | 7 | #include <optional> |
| 8 | #include <vector> | ||
| 8 | 9 | ||
| 9 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| @@ -113,7 +114,8 @@ std::optional<IPv4Address> GetHostIPv4Address(); | |||
| 113 | std::string IPv4AddressToString(IPv4Address ip_addr); | 114 | std::string IPv4AddressToString(IPv4Address ip_addr); |
| 114 | u32 IPv4AddressToInteger(IPv4Address ip_addr); | 115 | u32 IPv4AddressToInteger(IPv4Address ip_addr); |
| 115 | 116 | ||
| 116 | Common::Expected<std::vector<AddrInfo>, GetAddrInfoError> GetAddrInfo( | 117 | // named to avoid name collision with Windows macro |
| 118 | Common::Expected<std::vector<AddrInfo>, GetAddrInfoError> GetAddressInfo( | ||
| 117 | const std::string& host, const std::optional<std::string>& service); | 119 | const std::string& host, const std::optional<std::string>& service); |
| 118 | 120 | ||
| 119 | } // namespace Network | 121 | } // namespace Network |