ws2_32: Fix WSASocket return code for invalid combination of socket type and protocol.
This commit is contained in:
parent
78ca87a00b
commit
5762067b20
|
@ -5867,6 +5867,7 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
|
|||
GROUP g, DWORD dwFlags)
|
||||
{
|
||||
SOCKET ret;
|
||||
DWORD err;
|
||||
|
||||
/*
|
||||
FIXME: The "advanced" parameters of WSASocketW (lpProtocolInfo,
|
||||
|
@ -5929,16 +5930,26 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (GetLastError() == WSAEACCES) /* raw socket denied */
|
||||
err = GetLastError();
|
||||
if (err == WSAEACCES) /* raw socket denied */
|
||||
{
|
||||
if (type == SOCK_RAW)
|
||||
ERR_(winediag)("Failed to create a socket of type SOCK_RAW, this requires special permissions.\n");
|
||||
else
|
||||
ERR_(winediag)("Failed to create socket, this requires special permissions.\n");
|
||||
SetLastError(WSAESOCKTNOSUPPORT);
|
||||
err = WSAESOCKTNOSUPPORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid combination of valid parameters, like SOCK_STREAM + IPPROTO_UDP */
|
||||
if (err == WSAEINVAL)
|
||||
err = WSAESOCKTNOSUPPORT;
|
||||
else if (err == WSAEOPNOTSUPP)
|
||||
err = WSAEPROTONOSUPPORT;
|
||||
}
|
||||
|
||||
WARN("\t\tfailed!\n");
|
||||
WARN("\t\tfailed, error %d!\n", err);
|
||||
SetLastError(err);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
|
|
|
@ -1854,7 +1854,6 @@ todo_wine
|
|||
ok(WSASocketA(AF_INET, 0xdead, 0, NULL, 0, 0) == INVALID_SOCKET,
|
||||
"WSASocketA should have failed\n");
|
||||
err = WSAGetLastError();
|
||||
todo_wine
|
||||
ok(err == WSAESOCKTNOSUPPORT, "Expected 10044, received %d\n", err);
|
||||
|
||||
SetLastError(0xdeadbeef);
|
||||
|
@ -1874,7 +1873,6 @@ todo_wine
|
|||
ok(WSASocketA(AF_INET, SOCK_STREAM, IPPROTO_UDP, NULL, 0, 0) == INVALID_SOCKET,
|
||||
"WSASocketA should have failed\n");
|
||||
err = WSAGetLastError();
|
||||
todo_wine
|
||||
ok(err == WSAEPROTONOSUPPORT, "Expected 10043, received %d\n", err);
|
||||
|
||||
/* SOCK_DGRAM does not support IPPROTO_TCP */
|
||||
|
@ -1882,7 +1880,6 @@ todo_wine
|
|||
ok(WSASocketA(AF_INET, SOCK_DGRAM, IPPROTO_TCP, NULL, 0, 0) == INVALID_SOCKET,
|
||||
"WSASocketA should have failed\n");
|
||||
err = WSAGetLastError();
|
||||
todo_wine
|
||||
ok(err == WSAEPROTONOSUPPORT, "Expected 10043, received %d\n", err);
|
||||
|
||||
/* Set pi_size explicitly to a value below 2*sizeof(WSAPROTOCOL_INFOA)
|
||||
|
|
Loading…
Reference in New Issue