Author: gedmurphy
Date: Thu Aug 17 20:44:54 2006
New Revision: 23595
URL:
http://svn.reactos.org/svn/reactos?rev=23595&view=rev
Log:
Don't allow ws2_32 access to apps with bad setup data
Modified:
trunk/reactos/dll/win32/ws2_32/misc/dllmain.c
Modified: trunk/reactos/dll/win32/ws2_32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/ws2_32/misc/dllm…
==============================================================================
--- trunk/reactos/dll/win32/ws2_32/misc/dllmain.c (original)
+++ trunk/reactos/dll/win32/ws2_32/misc/dllmain.c Thu Aug 17 20:44:54 2006
@@ -76,15 +76,61 @@
WSAStartup(IN WORD wVersionRequested,
OUT LPWSADATA lpWSAData)
{
+ BYTE Low, High;
+
WS_DbgPrint(MAX_TRACE, ("WSAStartup of ws2_32.dll\n"));
+ if (!g_hInstDll)
+ return WSASYSNOTREADY;
+
+ if (lpWSAData == NULL)
+ return WSAEFAULT;
+
+ Low = LOWBYTE(wVersionRequested);
+ High = HIGHBYTE(wVersionRequested);
+
+ if (Low < 1)
+ {
+ WS_DbgPrint(MAX_TRACE, ("Bad winsock version requested, %d,%d", Low,
High));
+ return WSAVERNOTSUPPORTED;
+ }
+
+ if (Low == 1)
+ {
+ if (High == 0)
+ {
+ lpWSAData->wVersion = wVersionRequested;
+ }
+ else
+ {
+ lpWSAData->wVersion = MAKEWORD(1, 1);
+ }
+ }
+ else if (Low == 2)
+ {
+ if (High <= 2)
+ {
+ lpWSAData->wVersion = MAKEWORD(2, High);
+ }
+ else
+ {
+ lpWSAData->wVersion = MAKEWORD(2, 2);
+ }
+ }
+ else
+ {
+ lpWSAData->wVersion = MAKEWORD(2, 2);
+ }
+
lpWSAData->wVersion = wVersionRequested;
- lpWSAData->wHighVersion = 2;
- lstrcpyA(lpWSAData->szDescription, "WinSock 2.0");
+ lpWSAData->wHighVersion = MAKEWORD(2,2);
+ lstrcpyA(lpWSAData->szDescription, "WinSock 2.2");
lstrcpyA(lpWSAData->szSystemStatus, "Running");
lpWSAData->iMaxSockets = 0;
lpWSAData->iMaxUdpDg = 0;
lpWSAData->lpVendorInfo = NULL;
+
+ /*FIXME: increment internal counter */
WSASETINITIALIZED;