Dan Kegel : ws2_32: Null select() should fail with WSAEINVAL.
Alexandre Julliard
julliard at winehq.org
Thu Dec 2 16:30:52 CST 2010
Module: wine
Branch: stable
Commit: 6eb260766cdb37616374fb4c7e11f113cc047c88
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6eb260766cdb37616374fb4c7e11f113cc047c88
Author: Dan Kegel <dank at kegel.com>
Date: Mon Oct 18 10:42:16 2010 +0000
ws2_32: Null select() should fail with WSAEINVAL.
(cherry picked from commit 6733c40d789744ec0ee6fa30f8e14816968a0887)
---
dlls/ws2_32/socket.c | 8 ++++++--
dlls/ws2_32/tests/sock.c | 11 +++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index 4c8a2db..8dffeeb 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -2975,7 +2975,11 @@ static struct pollfd *fd_sets_to_poll( const WS_fd_set *readfds, const WS_fd_set
if (writefds) count += writefds->fd_count;
if (exceptfds) count += exceptfds->fd_count;
*count_ptr = count;
- if (!count) return NULL;
+ if (!count)
+ {
+ SetLastError(WSAEINVAL);
+ return NULL;
+ }
if (!(fds = HeapAlloc( GetProcessHeap(), 0, count * sizeof(fds[0]))))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
@@ -3098,7 +3102,7 @@ int WINAPI WS_select(int nfds, WS_fd_set *ws_readfds,
TRACE("read %p, write %p, excp %p timeout %p\n",
ws_readfds, ws_writefds, ws_exceptfds, ws_timeout);
- if (!(pollfds = fd_sets_to_poll( ws_readfds, ws_writefds, ws_exceptfds, &count )) && count)
+ if (!(pollfds = fd_sets_to_poll( ws_readfds, ws_writefds, ws_exceptfds, &count )))
return SOCKET_ERROR;
if (ws_timeout)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 8d7c7a6..96430ff 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1941,6 +1941,17 @@ static void test_select(void)
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_ZERO(&exceptfds);
+
+ SetLastError(0);
+ ret = select(maxfd+1, 0, 0, 0, &select_timeout);
+ ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret);
+ ok ( GetLastError() == WSAEINVAL, "expected WSAEINVAL, got %i\n", ret);
+
+ SetLastError(0);
+ ret = select(maxfd+1, &readfds, &writefds, &exceptfds, &select_timeout);
+ ok ( (ret == SOCKET_ERROR), "expected SOCKET_ERROR, got %i\n", ret);
+ ok ( GetLastError() == WSAEINVAL, "expected WSAEINVAL, got %i\n", ret);
+
FD_SET(INVALID_SOCKET, &readfds);
SetLastError(0);
ret = select(maxfd+1, &readfds, &writefds, &exceptfds, &select_timeout);
More information about the wine-cvs
mailing list