From a990e25bf029913b08590d89841ec4faa89236b6 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Sun, 17 Oct 2021 23:45:29 -0600 Subject: [PATCH] ws2_32: Set WSAEFAULT if the bind address is null. Signed-off-by: Alex Henrie Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ws2_32/socket.c | 2 +- dlls/ws2_32/tests/sock.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 50ea15c5b0e..2db441bee3c 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -1068,7 +1068,7 @@ int WINAPI bind( SOCKET s, const struct sockaddr *addr, int len ) if (!addr) { - SetLastError( WSAEAFNOSUPPORT ); + SetLastError( WSAEFAULT ); return -1; } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index eadc47a8ea6..63f8149f160 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -10794,7 +10794,18 @@ static void test_bind(void) WSASetLastError(0xdeadbeef); ret = bind(s, NULL, 0); ok(ret == -1, "expected failure\n"); - todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError()); + ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError()); + + WSASetLastError(0xdeadbeef); + ret = bind(s, NULL, sizeof(addr)); + ok(ret == -1, "expected failure\n"); + ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError()); + + addr.sa_family = AF_INET; + WSASetLastError(0xdeadbeef); + ret = bind(s, &addr, 0); + ok(ret == -1, "expected failure\n"); + ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError()); addr.sa_family = 0xdead; WSASetLastError(0xdeadbeef);