Module: wine Branch: master Commit: 79387b2f9fa5c73ce45f2a6f98d3b036277cbccc URL: https://gitlab.winehq.org/wine/wine/-/commit/79387b2f9fa5c73ce45f2a6f98d3b03...
Author: Zebediah Figura zfigura@codeweavers.com Date: Tue Feb 7 19:35:37 2023 -0600
ws2_32: Forbid passing zero buffers to WSARecv().
---
dlls/ws2_32/socket.c | 6 ++++++ dlls/ws2_32/tests/sock.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index e8a04e2e714..2a8fcf01ed8 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -4035,6 +4035,12 @@ int WINAPI WSARecv(SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) { + if (!dwBufferCount) + { + SetLastError( WSAEINVAL ); + return -1; + } + return WS2_recv_base(s, lpBuffers, dwBufferCount, NumberOfBytesReceived, lpFlags, NULL, NULL, lpOverlapped, lpCompletionRoutine, NULL); } diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index d29e1c768dc..58dcf9e7f4e 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -12811,14 +12811,14 @@ static void test_empty_recv(void) WSASetLastError(0xdeadbeef); ret = WSARecv(client, NULL, 0, NULL, &flags, &overlapped, NULL); ok(ret == -1, "expected failure\n"); - todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError()); + ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError());
wsabuf.buf = buffer; wsabuf.len = 0; WSASetLastError(0xdeadbeef); ret = WSARecv(client, &wsabuf, 0, NULL, &flags, &overlapped, NULL); ok(ret == -1, "expected failure\n"); - todo_wine ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError()); + ok(WSAGetLastError() == WSAEINVAL, "got error %u\n", WSAGetLastError());
WSASetLastError(0xdeadbeef); ret = WSARecv(client, &wsabuf, 1, NULL, &flags, &overlapped, NULL);