diff options
author | Patric Stout <truebrain@openttd.org> | 2020-12-09 17:13:34 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2020-12-15 15:46:39 +0100 |
commit | 8fbf5bef60568cd4dcd56921c37be64b8234d9bb (patch) | |
tree | a234d6bea0d739dafe344ab64a2d71742e1eae85 /src/network/core/address.cpp | |
parent | d5b9f7ac37c7d27d1ffe50e55aa73361da64189b (diff) | |
download | openttd-8fbf5bef60568cd4dcd56921c37be64b8234d9bb.tar.xz |
Fix: workarounds for two emscripten bugs in the network stack
Diffstat (limited to 'src/network/core/address.cpp')
-rw-r--r-- | src/network/core/address.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index 1aaa0b5fb..2e00b5b19 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -267,6 +267,18 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList * this->address_length = (int)runp->ai_addrlen; assert(sizeof(this->address) >= runp->ai_addrlen); memcpy(&this->address, runp->ai_addr, runp->ai_addrlen); +#ifdef __EMSCRIPTEN__ + /* Emscripten doesn't zero sin_zero, but as we compare addresses + * to see if they are the same address, we need them to be zero'd. + * Emscripten is, as far as we know, the only OS not doing this. + * + * https://github.com/emscripten-core/emscripten/issues/12998 + */ + if (this->address.ss_family == AF_INET) { + sockaddr_in *address_ipv4 = (sockaddr_in *)&this->address; + memset(address_ipv4->sin_zero, 0, sizeof(address_ipv4->sin_zero)); + } +#endif break; } |