Bruno Jesus : ws2_32: Fix WSASocket return code for invalid combination of socket type and protocol .
Alexandre Julliard
julliard at winehq.org
Mon Sep 16 16:57:22 CDT 2013
Module: wine
Branch: master
Commit: 5762067b20dc3b0cc8d9fecb1a99d3784dc0131d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5762067b20dc3b0cc8d9fecb1a99d3784dc0131d
Author: Bruno Jesus <00cpxxx at gmail.com>
Date: Mon Sep 16 01:44:22 2013 -0300
ws2_32: Fix WSASocket return code for invalid combination of socket type and protocol.
---
dlls/ws2_32/socket.c | 17 ++++++++++++++---
dlls/ws2_32/tests/sock.c | 3 ---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index b591c5e..dafbeb4 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -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;
}
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index bc2bd10..40496ca 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -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)
More information about the wine-cvs
mailing list