[1/7] ws2_32: Don't try to receive data in an OOB_INLINED socket with MSG_OOB
Bruno Jesus
00cpxxx at gmail.com
Sat Mar 28 22:53:11 CDT 2015
The tests already exist and work by chance because GNU/Linux returns
EINVAL when attempting to read a socket that has no OOB data, that is
a "bug" for us and will be fixed in other patch (not in this series).
-------------- next part --------------
---
dlls/ws2_32/socket.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index e7e3de5..1bcb63c 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -6713,7 +6713,7 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
{
unsigned int i, options;
int n, fd, err, overlapped;
- struct ws2_async *wsa, localwsa;
+ struct ws2_async *wsa = NULL, localwsa;
BOOL is_blocking;
DWORD timeout_start = GetTickCount();
ULONG_PTR cvalue = (lpOverlapped && ((ULONG_PTR)lpOverlapped->hEvent & 1) == 0) ? (ULONG_PTR)lpOverlapped : 0;
@@ -6728,6 +6728,18 @@ static int WS2_recv_base( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
if (fd == -1) return SOCKET_ERROR;
+ if (*lpFlags & WS_MSG_OOB)
+ {
+ /* It's invalid to receive OOB data from an OOBINLINED socket
+ * as OOB data is turned into normal data. */
+ i = sizeof(n);
+ if (!getsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char*) &n, &i) && n)
+ {
+ err = WSAEINVAL;
+ goto error;
+ }
+ }
+
overlapped = (lpOverlapped || lpCompletionRoutine) &&
!(options & (FILE_SYNCHRONOUS_IO_ALERT | FILE_SYNCHRONOUS_IO_NONALERT));
if (overlapped || dwBufferCount > 1)
--
2.1.4
More information about the wine-patches
mailing list