[PATCH v5] ws2_32: Return WSAEAFNOSUPPORT when ip4/6 disabled
Brendan McGrath
brendan at redmandi.com
Wed Nov 21 13:02:39 CST 2018
Just following up on version 5 of this patch as I haven't heard any
feedback (and want to make sure it hasn't been overlooked).
On 16/11/18 10:27 am, Brendan McGrath wrote:
> 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
>
> Signed-off-by: Brendan McGrath <brendan at redmandi.com>
> ---
> Changes since v4:
> - from the server: map EAFNOSUPPORT from the kernel to STATUS_NOT_IMPLEMENTED
> - in ws2_32: map STATUS_NOT_IMPLEMENTED to WSAEAFNOSUPPORT
>
> It's still a bit ugly - but short of changing the design by removing the need
> for a NTSTATUS - I'm not sure there's a better way.
>
> dlls/ws2_32/socket.c | 1 +
> server/sock.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
> index df068fe8527..1d433086f11 100644
> --- a/dlls/ws2_32/socket.c
> +++ b/dlls/ws2_32/socket.c
> @@ -1067,6 +1067,7 @@ static inline DWORD NtStatusToWSAError( const DWORD status )
> case STATUS_BUFFER_OVERFLOW: wserr = WSAEMSGSIZE; break;
> case STATUS_NOT_SUPPORTED: wserr = WSAEOPNOTSUPP; break;
> case STATUS_HOST_UNREACHABLE: wserr = WSAEHOSTUNREACH; break;
> + case STATUS_NOT_IMPLEMENTED: wserr = WSAEAFNOSUPPORT; break;
>
> default:
> wserr = RtlNtStatusToDosError( status );
> diff --git a/server/sock.c b/server/sock.c
> index a8e6e28599b..dfcbab530fe 100644
> --- a/server/sock.c
> +++ b/server/sock.c
> @@ -912,8 +912,8 @@ static int sock_get_ntstatus( int err )
> case EPROTONOSUPPORT:
> case ESOCKTNOSUPPORT:
> case EPFNOSUPPORT:
> - case EAFNOSUPPORT:
> case EPROTOTYPE: return STATUS_NOT_SUPPORTED;
> + case EAFNOSUPPORT: return STATUS_NOT_IMPLEMENTED;
> case ENOPROTOOPT: return STATUS_INVALID_PARAMETER;
> case EOPNOTSUPP: return STATUS_NOT_SUPPORTED;
> case EADDRINUSE: return STATUS_ADDRESS_ALREADY_ASSOCIATED;
More information about the wine-devel
mailing list