Skip to content

Commit c2fc6d4

Browse files
committed
[MSWSOCK]
- Add another parameter check inside the FIONBIO code - Implement FIONREAD - Pass any unhandled I/O control codes to our helper DLL - This commit should be backported to msafd svn path=/branches/aicom-network-branch/; revision=48521
1 parent ffedb05 commit c2fc6d4

File tree

1 file changed

+38
-5
lines changed

1 file changed

+38
-5
lines changed

dll/win32/mswsock/msafd/sockopt.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ WSPIoctl(IN SOCKET Handle,
213213
PSOCKET_INFORMATION Socket;
214214
INT ErrorCode;
215215
PWINSOCK_TEB_DATA ThreadData;
216-
BOOLEAN Blocking;
216+
BOOLEAN Blocking, NeedsCompletion;
217217

218218
/* Enter prolog */
219219
ErrorCode = SockEnterApiFast(&ThreadData);
@@ -240,7 +240,7 @@ WSPIoctl(IN SOCKET Handle,
240240

241241
case FIONBIO:
242242
/* Check if the Buffer is OK */
243-
if(cbInBuffer < sizeof(ULONG))
243+
if(cbInBuffer < sizeof(ULONG) || IS_INTRESOURCE(lpvInBuffer))
244244
{
245245
/* Fail */
246246
ErrorCode = WSAEFAULT;
@@ -258,10 +258,43 @@ WSPIoctl(IN SOCKET Handle,
258258
NULL);
259259
break;
260260

261-
default:
261+
case FIONREAD:
262+
if(cbOutBuffer < sizeof(ULONG) || IS_INTRESOURCE(lpvOutBuffer))
263+
{
264+
*lpErrno = WSAEFAULT;
265+
return SOCKET_ERROR;
266+
}
267+
268+
ErrorCode = SockGetInformation(Socket,
269+
AFD_INFO_RECEIVE_CONTENT_SIZE,
270+
NULL,
271+
0,
272+
NULL,
273+
(PULONG)lpvOutBuffer,
274+
NULL);
275+
276+
if (ErrorCode == NO_ERROR) *lpcbBytesReturned = sizeof(ULONG);
277+
break;
262278

263-
/* Unsupported for now */
264-
ErrorCode = WSAEINVAL;
279+
default:
280+
/* Unsupported by us, give it to the helper */
281+
ErrorCode = SockGetTdiHandles(Socket);
282+
if (ErrorCode != NO_ERROR) goto error;
283+
284+
/* Call the helper */
285+
ErrorCode = Socket->HelperData->WSHIoctl(Socket->HelperContext,
286+
Handle,
287+
Socket->TdiAddressHandle,
288+
Socket->TdiConnectionHandle,
289+
dwIoControlCode,
290+
lpvInBuffer,
291+
cbInBuffer,
292+
lpvOutBuffer,
293+
cbOutBuffer,
294+
lpcbBytesReturned,
295+
lpOverlapped,
296+
lpCompletionRoutine,
297+
(LPBOOL)&NeedsCompletion);
265298
break;
266299
}
267300

0 commit comments

Comments
 (0)