ws2_32: Set WSAEFAULT if the bind address is null.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alex Henrie 2021-10-17 23:45:29 -06:00 committed by Alexandre Julliard
parent 63110f9879
commit a990e25bf0
2 changed files with 13 additions and 2 deletions

View File

@ -1068,7 +1068,7 @@ int WINAPI bind( SOCKET s, const struct sockaddr *addr, int len )
if (!addr)
{
SetLastError( WSAEAFNOSUPPORT );
SetLastError( WSAEFAULT );
return -1;
}

View File

@ -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);