[PATCH v2] ws2_32: Return WSAEAFNOSUPPORT when ip4/6 disabled
Brendan McGrath
brendan at redmandi.com
Tue Nov 13 06:36:53 CST 2018
Currently, when IPv6 is disabled by the kernel, attempting to use
the 'WebRequest' API with .NET native causes a crash. This can be
recreated using the following gist:
https://gist.github.com/redmcg/7d81ef833c77bee6965b5f441006f697
This patch fixes the crash by returning WSAEAFNOSUPPORT, as expected
by .NET. See:
https://referencesource.microsoft.com/#System/net/System/Net/Sockets/Socket.cs,5995
---
Changes since v1:
- fixed compile error (sorry - I had tested against the wrong branch)
dlls/ws2_32/socket.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index df068fe8527..956ead2e9d5 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -7646,6 +7646,8 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
/* invalid combination of valid parameters, like SOCK_STREAM + IPPROTO_UDP */
if (err == WSAEINVAL)
err = WSAESOCKTNOSUPPORT;
+ else if (err == WSAEOPNOTSUPP && (unixaf == AF_INET || unixaf == AF_INET6))
+ err = WSAEAFNOSUPPORT;
else if (err == WSAEOPNOTSUPP)
err = WSAEPROTONOSUPPORT;
}
--
2.17.1
More information about the wine-devel
mailing list