Author: cgutman
Date: Thu Aug 11 07:08:16 2011
New Revision: 53174
URL:
http://svn.reactos.org/svn/reactos?rev=53174&view=rev
Log:
[MSAFD]
- Implement SO_LINGER and SO_DONTLINGER for getsockopt and setsockopt
- Fix and add buffer size checks
- Yes, we've gone this long without SO_LINGER support
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Thu Aug 11 07:08:16 2011
@@ -2034,7 +2034,7 @@
PSOCKET_INFORMATION Socket = NULL;
PVOID Buffer;
INT BufferSize;
- BOOLEAN BoolBuffer;
+ BOOL BoolBuffer;
/* Get the Socket Structure associate to this Socket*/
Socket = GetSocketStructure(Handle);
@@ -2069,29 +2069,38 @@
case SO_ACCEPTCONN:
BoolBuffer = Socket->SharedData.Listening;
Buffer = &BoolBuffer;
- BufferSize = sizeof(BOOLEAN);
+ BufferSize = sizeof(BOOL);
break;
case SO_BROADCAST:
BoolBuffer = Socket->SharedData.Broadcast;
Buffer = &BoolBuffer;
- BufferSize = sizeof(BOOLEAN);
+ BufferSize = sizeof(BOOL);
break;
case SO_DEBUG:
BoolBuffer = Socket->SharedData.Debug;
Buffer = &BoolBuffer;
- BufferSize = sizeof(BOOLEAN);
+ BufferSize = sizeof(BOOL);
break;
+ case SO_DONTLINGER:
+ BoolBuffer = (Socket->SharedData.LingerData.l_onoff == 0);
+ Buffer = &BoolBuffer;
+ BufferSize = sizeof(BOOL);
+ break;
+
+ case SO_LINGER:
+ Buffer = &Socket->SharedData.LingerData;
+ BufferSize = sizeof(struct linger);
+ break;
+
/* case SO_CONDITIONAL_ACCEPT: */
- case SO_DONTLINGER:
case SO_DONTROUTE:
case SO_ERROR:
case SO_GROUP_ID:
case SO_GROUP_PRIORITY:
case SO_KEEPALIVE:
- case SO_LINGER:
case SO_MAX_MSG_SIZE:
case SO_OOBINLINE:
case SO_PROTOCOL_INFO:
@@ -2155,8 +2164,36 @@
switch (optname)
{
case SO_BROADCAST:
+ if (optlen < sizeof(BOOL))
+ {
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
Socket->SharedData.Broadcast = (*optval != 0) ? 1 : 0;
return 0;
+
+ case SO_DONTLINGER:
+ if (optlen < sizeof(BOOL))
+ {
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ Socket->SharedData.LingerData.l_onoff = (*optval != 0) ? 0 : 1;
+ return 0;
+
+ case SO_LINGER:
+ if (optlen < sizeof(struct linger))
+ {
+ *lpErrno = WSAEFAULT;
+ return SOCKET_ERROR;
+ }
+ RtlCopyMemory(&Socket->SharedData.LingerData,
+ optval,
+ sizeof(struct linger));
+ return 0;
+
+ default:
+ break;
}
}