[5/5] ws2_32: Fix the error returned for denied SOCK_RAW attempts
Bruno Jesus
00cpxxx at gmail.com
Sun Sep 15 23:44:40 CDT 2013
-------------- next part --------------
---
dlls/ws2_32/socket.c | 1 -
dlls/ws2_32/tests/sock.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index dafbeb4..4750656 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -5937,7 +5937,6 @@ SOCKET WINAPI WSASocketW(int af, int type, int protocol,
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");
- err = WSAESOCKTNOSUPPORT;
}
else
{
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 4c58934..230b4fe 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -2050,6 +2050,53 @@ todo_wine
}
HeapFree(GetProcessHeap(), 0, pi);
+
+ SetLastError(0xdeadbeef);
+ /* starting on vista the socket function returns error during the socket
+ creation and no longer in the socket operations (sendto, readfrom) */
+ sock = WSASocketA(AF_INET, SOCK_RAW, IPPROTO_ICMP, NULL, 0, 0);
+ if (sock == INVALID_SOCKET)
+ {
+ err = WSAGetLastError();
+ ok(err == WSAEACCES, "Expected 10013, received %d\n", err);
+ skip("SOCK_RAW is not supported\n");
+ }
+ else
+ {
+ trace("SOCK_RAW is supported\n");
+
+ size = sizeof(socktype);
+ socktype = 0xdead;
+ err = getsockopt(sock, SOL_SOCKET, SO_TYPE, (char *) &socktype, &size);
+ ok(!err, "getsockopt failed with %d\n", WSAGetLastError());
+ ok(socktype == SOCK_RAW, "Wrong socket type, expected %d received %d\n",
+ SOCK_RAW, socktype);
+ closesocket(sock);
+
+ todo_wine {
+ sock = WSASocketA(0, 0, IPPROTO_RAW, NULL, 0, 0);
+ ok(sock != INVALID_SOCKET, "Failed to create socket: %d\n",
+ WSAGetLastError());
+ size = sizeof(socktype);
+ socktype = 0xdead;
+ err = getsockopt(sock, SOL_SOCKET, SO_TYPE, (char *) &socktype, &size);
+ ok(!err, "getsockopt failed with %d\n", WSAGetLastError());
+ ok(socktype == SOCK_RAW, "Wrong socket type, expected %d received %d\n",
+ SOCK_RAW, socktype);
+ closesocket(sock);
+ }
+
+ sock = WSASocketA(AF_INET, SOCK_RAW, IPPROTO_TCP, NULL, 0, 0);
+ ok(sock != INVALID_SOCKET, "Failed to create socket: %d\n",
+ WSAGetLastError());
+ size = sizeof(socktype);
+ socktype = 0xdead;
+ err = getsockopt(sock, SOL_SOCKET, SO_TYPE, (char *) &socktype, &size);
+ ok(!err, "getsockopt failed with %d\n", WSAGetLastError());
+ ok(socktype == SOCK_RAW, "Wrong socket type, expected %d received %d\n",
+ SOCK_RAW, socktype);
+ closesocket(sock);
+ }
}
static void test_WSADuplicateSocket(void)
--
1.8.3.2
More information about the wine-patches
mailing list